我使用Wildfly 8.2.0 Final设置了一个web应用程序。我现在正在尝试创建一个jms主题,并通过2个bean发送和接收一些消息。
Bean 1是我的发件人/发布者:
@Stateless
public class ChatPublisherBean implements ChatPublisherLocal, ChatPublisherRemote {
@JMSConnectionFactory("java:/ConnectionFactory")
private ConnectionFactory connectionFactory;
@Resource(lookup = "java:global/jms/ChatRoomTopic")
private Topic topic;
//more code ...
Bean 2我的接收者/消费者:
@MessageDriven(mappedName = "java:global/jms/ChatRoomTopic",
messageListenerInterface = MessageListener.class,
activationConfig = {
@ActivationConfigProperty(
propertyName = "destinationType",
propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(
propertyName = "destination",
propertyValue = "java:global/jms/ChatRoomTopic")})
public class ChatReceiverBean implements MessageListener, ChatReceiverLocal, ChatReceiverRemote {
@Inject
private ChatServiceLocal chatService;
@Inject
private ChatPublisherBean jmsConnectionBean;
//more code
正如你所看到我使用jms 2.0的自动资源生成(或者至少我试过),它与ConnectionFactory配合得很好,因为我在那里使用标准工厂。
现在的问题是,当我尝试部署它时,我的主题找不到正确。 Wildfly给了我这个错误:
19:03:38,187 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "app.ear")]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.deployment.subunit.\"app.ear\".\"core-ejb.jar\".component.ChatReceiverBean.CREATE is missing [jboss.ra.hornetq-ra]",
"jboss.naming.context.java.comp.app.core-ejb.ChatPublisherBean.env.\"de.app.platform.chat.services.jms.ChatPublisherBean\".topic is missing [jboss.naming.context.java.global.jms.ChatRoomTopic]"
]}
19:03:38,188 ERROR [org.jboss.as.server] (management-handler-thread - 2) JBAS015870: Deploy of deployment "app.ear" was rolled back with the following failure message:
{"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.deployment.subunit.\"app.ear\".\"core-ejb.jar\".component.ChatReceiverBean.CREATE is missing [jboss.ra.hornetq-ra]",
"jboss.naming.context.java.comp.app.core-ejb.ChatPublisherBean.env.\"de.app.platform.chat.services.jms.ChatPublisherBean\".topic is missing [jboss.naming.context.java.global.jms.ChatRoomTopic]"
同样,我的standalone.xml声明为标准的hornetq适配器似乎有问题:
<mdb>
<resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:hornetq-ra}"/>
<bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
</mdb>
现在有人在做错吗?
答案 0 :(得分:0)
我总是不得不在代码之外创建主题。我有一个小脚本,我运行它来设置它们。相关部分类似于:
$WILDFLY_HOME/bin/jboss-cli.sh --connect --command="jms-topic add --topic-address=ChatRoomTopic --entries=java:/jms/ChatRoomTopic
稍后,如果你想删除它:
$WILDFLY_HOME/bin/jboss-cli.sh --connect --command="jms-topic remove --topic-address=ChatRoomTopic
这是在Wildfly 8.2中完成的。