@Singleton
クラスをではなくに変えるために、別の質問からの提案ごとにいくつかの変更を加えましたが、以前のように Bean@Stateless
でメッセージを受信しなくなりました。@MessageDriven
提案?トピックが正しく定義されていることに注意してくださいjbossmq-destinations-service.xml
@javax.ejb.Singleton(mappedName="MySingletonClass")
public class MySingletonClass implements SomeInterface
{
private Timer timer = null;
@javax.annotation.Resource
TimerService timerService;
/**
* Creates the timer.
*/
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void resetTimer()
{
if (timer != null)
{
timer.cancel();
}
timer = timerService.createTimer(30000, "Note");
}
@Override
public void readResponseMsg(Document responseXml)
{
resetTimer();
//Do stuff
}
@Override
@Timeout
public void timeout() throws RemoteException
{
//do stuff
}
}
および MDB:
@javax.ejb.MessageDriven(mappedName = "jms/MyTopic", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "MyTopic"),
@ActivationConfigProperty(propertyName = "messagingType", propertyValue = "javax.jms.MessageListener"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
@ResourceAdapter("activemq.rar")
public class MyMDB implements MessageListener
{
private static final Logger ourLogger = Logger.getLogger(MyMDB.class);
@javax.ejb.EJB(mappedName="MySingletonClass") private MySingletonClassInterface reader;
/**
* @param message
*/
public void onMessage(Message message)
{
TextMessage textMessage = (TextMessage) message;
try
{
System.out.println("Received Message Text: " + textMessage.getText());
reader.readResponseMsg(loadXMLFromString(textMessage.getText()));
}
catch (JMSException | SAXException | ParserConfigurationException | IOException e)
{
ourLogger.error("Exception handling Schedule Results Message", e);
}
}
}
これはインターフェースです:
@javax.ejb.Local
public interface SomeInterface
{
public void readResponseMsg(Document responseXml);
public void timeout() throws RemoteException;
}
更新私はいくつかのことをいじっていましたが、少なくとも何かが起こっていることを示す例外がいくつか見られます。上記のコードを変更して更新しました。これは私の例外です:
Caused by: javax.naming.NameNotFoundException: MySingletonClass not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final]
at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final]
at org.jnp.server.NamingServer.getObject(NamingServer.java:785) [:5.0.5.Final]
at org.jnp.server.NamingServer.lookup(NamingServer.java:396) [:5.0.5.Final]
at org.jnp.server.NamingServer.lookup(NamingServer.java:399) [:5.0.5.Final]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728) [:5.0.5.Final]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688) [:5.0.5.Final]
at javax.naming.InitialContext.lookup(InitialContext.java:411) [:1.7.0_25]
at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1350) [:5.0.5.Final]
... 61 more
また、JBoss 6 起動ログのさらに上に、これも表示されます。
[BeanInstantiatorDeployerBase] Installed org.jboss.ejb3.instantiator.impl.Ejb31SpecBeanInstantiator@fbda95 into MC at org.jboss.ejb.bean.instantiator/mmpl/server/MySingletonClass
次に、ログを少し下に移動します。
DEPLOYMENTS MISSING DEPENDENCIES:
Deployment "jboss-switchboard:appName=mmpl,module=server,name=MyMDB" is missing the following dependencies:
Dependency "jboss.j2ee:ear=mmpl.ear,jar=server.jar,name=MySingletonClass,service=EJB3" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'jboss.j2ee:ear=mmpl.ear,jar=server.jar,name=MySingletonClass,service=EJB3',whenRequired=MapControllerStateModel$ControllerStateWrapper@7ba014{Installed},dependentState=MapControllerStateModel$ControllerStateWrapper@7ba014{Installed} **")
Deployment "jboss.j2ee:ear=mmpl.ear,jar=server.jar,name=MySingletonClass,service=EJB3_endpoint" is missing the following dependencies:
Dependency "jboss.j2ee:ear=mmpl.ear,jar=server.jar,name=MySingletonClass,service=EJB3" (should be in state "Installed", but is actually in state "** NOT FOUND Depends on 'jboss.j2ee:ear=mmpl.ear,jar=server.jar,name=MySingletonClass,service=EJB3' **")
DEPLOYMENTS IN ERROR:
Deployment "jboss.j2ee:ear=mmpl.ear,jar=server.jar,name=MySingletonClass,service=EJB3" is in error due to the following reason(s): ** NOT FOUND Depends on 'jboss.j2ee:ear=mmpl.ear,jar=server.jar,name=MySingletonClass,service=EJB3',whenRequired=MapControllerStateModel$ControllerStateWrapper@7ba014{Installed},dependentState=MapControllerStateModel$ControllerStateWrapper@7ba014{Installed} **, ** NOT FOUND Depends on 'jboss.j2ee:ear=mmpl.ear,jar=server.jar,name=MySingletonClass,service=EJB3' **