0

I'm trying to configure WildFly 10.1.0 to use MDB's with context of the remote ActiveMQ server. Problem occures when trying to use injected remote JMSContext - naming exception(looking for transaction). Steps I did:

  1. WildFly standalone-full.xml configuration: (only added entries are listed)
  • Output Socket Binding

    <socket-binding-group>
        ...
        <outbound-socket-binding name="remote-artemis">
            <remote-destination host="192.168.56.10" port="61616"/>
        </outbound-socket-binding>
    </socket-binding-group>
    
  • Messaging configuration

    <subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
            <server name="default">
               <remote-connector name="remote-artemis" socket-binding="remote-artemis"/>
               <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
               <pooled-connection-factory name="remote-artemis" entries="java:/jms/remoteCF" connectors="remote-artemis" user="foo" password="bar"/>
              </server>
    

  • Naming Configuration - where external context is configured

    <subsystem xmlns="urn:jboss:domain:naming:2.0">
            <bindings>
                <external-context name="java:/remote/artemis/" module="org.wildfly.extension.messaging-activemq" class="javax.naming.InitialContext" cache="true">
                    <environment>
                        <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
                        <property name="java.naming.provider.url" value="tcp://192.168.56.10:61616"/>
                    </environment>
                </external-context>
            </bindings>
            <remote-naming/>
        </subsystem>
    
  1. Standalone Artemis ActiveMQ configuration (server is running on linux as a service)
  • added foo=bar user, with admin rights
  • JAAS Security is used
  • added queue name="example.queue" to tms broker
  1. Usage
  • Sample Consumer
@MessageDriven(name = "MessageConsiumer", activationConfig = {                
@ActivationConfigProperty(propertyName = "connectionFactoryLookup", propertyValue = "java:/jms/remoteCF"),     
@ActivationConfigProperty(propertyName="user", propertyValue="foo"),
@ActivationConfigProperty(propertyName="password", propertyValue="bar"),
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:/remote/artemis/dynamicQueues/example.queue"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
public class MessageConsiumer implements MessageListener {
            @Override
            public void onMessage(Message message) {
                try {
                    TextMessage msg = (TextMessage) message;
                    System.out.println(msg.getText());
                } catch (JMSException e) {
                    e.printStackTrace();
                }   
            }
        }
  • Sample Producer

        public class MessageProducer {
    
    @Inject
    @JMSConnectionFactory("java:/jms/remoteCF")
    @JMSPasswordCredential(userName = "foo", password = "bar")
    private JMSContext context;
    
    @Resource(lookup = "java:/remote/artemis/dynamicQueues/example.queue")
    private Queue queue;
    
    @PostConstruct
    public void send(){
     TextMessage msg = context.createTextMessage();
     msg.setText("Sample text");
     context.createProducer().send(queue, msg);
    }
    

Result

It seems that JMSContext and destination Queue is injected properly(debugged). Error occures at runtime, on first JMSContext usage i.e.:

TextMessage msg = context.createTextMessage();

Naming exception is popping out, looking for comp/TransactionSynchronizationRegistry.

Is that up to standalone activeMQ transaction configuration? Or maybe is that wildfly's side? Any ideas what might that be?

  • Stacktrace

Caused by: java.lang.RuntimeException: javax.naming.NameNotFoundException: comp/TransactionSynchronizationRegistry -- service jboss.naming.context.java.comp.TransactionSynchronizationRegistry at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.lookup(InjectedJMSContext.java:134) at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.getTransactionSynchronizationRegistry(InjectedJMSContext.java:109) at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.isInTransaction(InjectedJMSContext.java:98) at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.getDelegate(InjectedJMSContext.java:87) at org.wildfly.extension.messaging.activemq.deployment.injection.JMSContextWrapper.createProducer(JMSContextWrapper.java:66) at testr.messaging.MessageProductioner.sendThat(MessageProductioner.java:54) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:57) at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:61) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437) at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82) at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:95) at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:61) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:57) at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:61) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ejb3.tx.EjbBMTInterceptor.handleInvocation(EjbBMTInterceptor.java:103) ... 49 more Caused by: javax.naming.NameNotFoundException: comp/TransactionSynchronizationRegistry -- service jboss.naming.context.java.comp.TransactionSynchronizationRegistry at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189) at org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:223) at javax.naming.InitialContext.lookup(InitialContext.java:417) at javax.naming.InitialContext.lookup(InitialContext.java:417) at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.lookup(InjectedJMSContext.java:132) ... 74 more

AndreyB
  • 55
  • 10

0 Answers0