How to configure a JMS Topic Endpoint

mattshaw's picture

Hi,

I have an existing ActiveMQ 4.1.1 installation as part of our system.  It has a number of predefined topics that we use to publish messages.  The clients are configured with a jndi.properties file.   I believe I have correctly configured the ESB to connect to the ActiveMQ installation. 

1) What syntax do I use to configure one of my topics to be an endpoint in the ESB, i.e. what do I type in the endpoint address field to get it to send messages to my existing JMS Topic ?

2)  How do I create a Proxy to take messages from my exisitng JMS topic ? 

Also,  I have created a SMTP mail out endpoint which works correctly.  Is it possible to change the properties of the email such as the subject line, address from and whether the content is an attachment or in the main body of the email ?

Many Thanks

Matt Shaw

 

asankha's picture

The clients are configured

>The clients are configured with a jndi.properties file.   I believe I have correctly configured the >ESB to connect to the ActiveMQ installation.  Ok, I believe that you have also configured the axis2.xml file and the JMS connection factories etc. appropriately for your environment. >1) What syntax do I use to configure one of my topics to be an endpoint in the ESB, i.e. what >do I type in the endpoint address field to get it to send messages to my existing JMS Topic ? You could refer to the example # 251 (http://wso2.org/project/esb/java/1.5/docs/ESB_Samples.html#Sample251) i.e. jms:/YourTopicOrQueueName?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp; java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616 In the above notation, you specify the JMS Destination name, connection factory JNDI name, and the JNDI IC factory class and URL all within the service EPR. This form of an EPR is ok for one time JMS posts etc. e.g. when you want to dynamically decide where you want to post your message etc. Another form would be to specify a local definition of the connection information within the axis2.xml's JMS transport sender itself (like we do for JMS transport receiver) e.g. <transportSender name="jms" class="org.apache.synapse.transport.jms.JMSSender"><parameter name="myTopicConnectionFactory"> <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter> <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter> <parameter name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory</parameter> </parameter></transportSender> This allows the underlying transport to initialize and be ready to post messages using the specified connection information without using adhoc JMS connections like before. The EPR format would then be of the form i.e. jms:/YourTopicOrQueueName?transport.jms.ConnectionFactory=myTopicConnectionFactory >2)  How do I create a Proxy to take messages from my exisitng JMS topic ?  You simply specify that the JMS transport should be enabled for your proxy service (this will appear selectable only if enabled in the underlying axis2.xml when the ESB starts) and specify one or more of the following optional "parameters" to specify the destination to pick up messages from etc. See the table "Transport specific parameters" under http://wso2.org/project/esb/java/1.5/docs/ESB_Configuration_Language.html#proxy Typically, you may want to specify a parameter "transport.jms.Destination" to inform the proxy service of the JMS Destination it needs to listen on, and a parameter "transport.jms.ConnectionFactory" that links to a connection factory definition on the underlying axis2.xml's JMS transport sender section. If you want your JMS Proxy service to publish the response to a message received into another JMS destination you may use the "transport.jms.ReplyDestination" parameter >Also,  I have created a SMTP mail out endpoint which works correctly.  Is it possible to >change the properties of the email such as the subject line, address from and whether the >content is an attachment or in the main body of the email ? I think Ruwan or Upul would be in a better position to answer this one asankha
ruwan's picture

Mail Transport is not that Flexible

Hi Matt, We use the mail transport of axis2 inside the ESB which implements the following draft spec [1]. Unfortunately there is no option to set the Subject of the mail being sent, but you can set the From header. Even that is static and has to be specified in the axis2.xml in the mail transport sender configuration. To do so, you need to specify the property smtp.mail.from in that configuration. I am sorry, but according to this spec we can not change the way the mail is being sent. (always the message will be sent as an attachment). [1] - http://people.apache.org/~pzf/SMTPBase64Binding.html Thanks Ruwan Linton
mattshaw's picture

Topics don't seem to work

Hi, I have tried what you suggested and it seems to work for Queues but I can't get it to work for Topics.  I've included my axis2.xml and synapse.xml files.  With the Queues I can see from a jconsole session that the ActiveMQ server is creating Queues and publishing messsages but when I try to configure it to work with Topics I get nothing.  My applications uses Topics and those are working correctly, I just can't get the ESB to interact with Topics in the ActiveMQ server both as a source and as a publisher of data.  Have you any thoughts as to what it might be ? Many thanks Matt
upulg's picture

RE: Topics don't seem to work

There is a issue with JMS transports that it always try to create queue related JMS objects. So Topics do not work. Bug has been reported.  (https://issues.apache.org/jira/browse/SYNAPSE-185) This will be fixed soon. Thank you for pointing out this problem. Upul  
mattshaw's picture

Do you know when ?

Hi Upul, Thanks for letting me know.  Do you know when it might be fixed i.e. days/weeks/months ? Best regards Matt Shaw
asankha's picture

Hi Matt The issue is caused

Hi Matt The issue is caused by the code changes we did to support JMS 1.0.x in addition to JMS 1.1. The TopicConnectionFactory of ActiveMQ seems to implement both QueueConnectionFactory and TopicConnectionFactory - and thus this confuses our code which checks if its a QCF or TCF. The change is a couple of days of work and you could expect this fixed in a nightly build towards early-mid next week asankha
mattshaw's picture

Fix Upate

Hi Asankha, Have you got an update as to when the fix might be available ? Thanks Matt
upulg's picture

RE: Fix Update

Hi Matt, A fix has been committed to the source.  You can expect it to be available in the next nightly build.   Upul  
upulg's picture

Now destination type can be

Now destination type can be given as a parameter. transport.jms.DestinationType = queue OR topic JMS sender example (modified sample 251) ------------------------------------------------------------ <definitions xmlns="http://ws.apache.org/ns/synapse">     <proxy name="StockQuoteProxy" transports="http">         <target>             <endpoint>               <address uri="jms:/SimpleStockQuoteService?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616&amp;transport.jms.DestinationType=topic"/>             </endpoint>             <inSequence>                 <property action="set" name="OUT_ONLY" value="true"/>             </inSequence>             <outSequence>                 <send/>             </outSequence>         </target>         <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/>     </proxy> </definitions>   JMS listener example (modified sample 250) ------------------------------------------------------------- <definitions xmlns="http://ws.apache.org/ns/synapse">     <proxy name="StockQuoteProxy" transports="jms">       <parameter name="transport.jms.DestinationType">topic</parameter>         <target>             <inSequence>                 <property action="set" name="OUT_ONLY" value="true"/>             </inSequence>             <endpoint>                 <address uri="http://localhost:9000/soap/SimpleStockQuoteService"/>             </endpoint>             <outSequence>                 <send/>             </outSequence>         </target>         <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/>     </proxy> </definitions>   Documentation and samples will be updated with the finalized settings. Upul
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)