8 Replies Latest reply on Aug 14, 2014 5:21 AM by jorgemoralespou_2

    JMS binding configuration

    jorgemoralespou_2

      Hi,

      I have some questions regarding JMS binding configuration.

       

      • For connectionFactory and transactionManager I guess that what can be input from JBDS is the connection factory name from the JBossAS console. What is the # for in the default Connectionfactory that gets shipped wiht the distro?
      • Hos is the connectionFactory name translated to the jndiConnectionFactory that is the one used in the JMSEndpoint?
      • How can I specify a custom transaction manager? What should be input here (in JBDS) the transactionManager name, class,...?
      • Can I provide a custom jndi.properties file for my binding? How?
      • Can the message type be specified, or it is discovered at runtime when sending/receiving messages? If it can be specified, how?

       

      Thanks

        • 1. Re: JMS binding configuration
          igarashitm

          Hi Jorge, sorry I didn't notice this thread

           

          • For connectionFactory and transactionManager I guess that what can be input from JBDS is the connection factory name from the JBossAS console. What is the # for in the default Connectionfactory that gets shipped wiht the distro?
          • Hos is the connectionFactory name translated to the jndiConnectionFactory that is the one used in the JMSEndpoint?

          # notation indicates the object should be resolved from camel registry. I'm not sure who lookup the ConnectionFactory instance from JNDI and put into camel registry though. At least Camel or Springframework does it.

          http://camel.apache.org/jms.html

          http://camel.apache.org/how-do-i-configure-endpoints.html - Using Endpoint URIs - Referring beans from Endpoint URIs

           

          • How can I specify a custom transaction manager? What should be input here (in JBDS) the transactionManager name, class,...?

          The transactionManager parameter expects a reference to the springframework PlatformTransactionManager instance. So if you implement it and put the instance into camel registry, then you can use it with specifying that bean name with # notation. The jtaTransactionManager and jmsTransactionManager are available out of the box.

           

          • Can I provide a custom jndi.properties file for my binding? How?

          As far as I know camel doesn't accept jndi properties for connectionfactory lookup. You may need to create JmsComponent producer which lookup the ConnectionFactory from JNDI and set it into JmsComponent.

          @ApplicationScoped
          public class MyJmsFactory {
              @Produces @Named("jms")
              public JmsComponent create() {
                  JmsComponent jms = new JmsComponent();
                  jms.setConnectionFactory(lookupRemoteConnectionFactory());
                  return jms;
              }
          }
          
          

           

          • Can the message type be specified, or it is discovered at runtime when sending/receiving messages? If it can be specified, how?

          By default Camel automatically determine which JMS message type is appropriate for the body of camel IN message. Camel does have jmsMessageType option to force output message type, but SwitchYard camel-jms binding schema doesn't support it right now. Feel free to file a enhancement request. Once it's supported in SwitchYard schema, you can specify the output message type in the binding.jms configuration.

           

          hth,

          Tomo

          • 2. Re: JMS binding configuration
            jorgemoralespou_2

            Hi,

            What is by default added by SwitchYard to the camel registry?

            How can we add something to the camel Registry in SwitchYard?  "So if you implement it and put the instance into camel registry, then you can use it with specifying that bean name with # notation"

            • 3. Re: JMS binding configuration
              kcbabo

              The registry includes anything in JNDI and beans discovered by CDI.  The "ConnectionFactory" connection factory is defined in EAP standalone configuration and stored in JNDI, which is why it can be resolved through the Camel registry using "#" notation.  If you want to put your own bean into the registry, you can define it as a CDI bean or you can get hold of the CamelContext (it's a property on ServiceDomain) and push an object directly into the registry.

              • 4. Re: JMS binding configuration
                kcbabo

                One note on the JMS message type, I believe this is already supported for JCA bindings and can be specified using the extra URI properties config setting for JMS bindings.  We should support this as a first-class config element for JMS bindings, however.

                • 5. Re: JMS binding configuration
                  jorgemoralespou_2

                  Hi,

                  I guess that it is not possible to add a bean to the camel registry within an XML defined camel route, anywhere else, bean and Java Camel would do, but then, would this bean be usable while configuring a binding?

                  Also, I agree on the message type comment, should be first class citizen at least from jbds. I did create a jira for this already, before your comment.

                   

                  Cheers

                  • 6. Re: JMS binding configuration
                    igarashitm
                    • 7. Re: JMS binding configuration
                      igarashitm

                      All you need to do is just create a bean class and add @Named annotation on it, then camel automatically detects the named CDI bean and puts it into registry on startup. Sure it'll be visible for SwitchYard as well.

                      • 8. Re: JMS binding configuration
                        jorgemoralespou_2

                        Hi Tomo,

                        This works even if deployed on the same artifact (deployable unit). I guess that CDI kicks in before deploying and activating the binding.

                        I'll try it as it seems very useful.

                         

                        Cheers,