You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by jeff1331 <jg...@voyence.com> on 2007/12/06 18:46:23 UTC

JMS consumer issue

Ok, I've given this a whirl for a few days, would appreciate some help. We
have a JMS topic publishing events and I want to connect to it via service
mix. I've been attempting to use the servicemix-jms component.

I've worked through most of the issues but there is one hurdle I can't seem
to get over. The topic requires a username and password when the connection
is created. In code, it looks like this:

/*********** java code
TopicConnectionFactory factory = (TopicConnectionFactory)
ctx.lookup("ConnectionFactory");
Topic eventTopic = (Topic) ctx.lookup(topicName);
System.out.println("Found JMS topic.");

TopicConnection topicConnection = factory.createTopicConnection("xyzUser",
"xyzPass");

TopicSession topicSession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
TopicSubscriber topicSubscriber = topicSession.createSubscriber(eventTopic);
System.out.println("Connected to topic.");
topicSubscriber.setMessageListener(this);
********** end java code */

Notice the factory.createTopicConnection() method taking the username and
password.

In my xbean.xml configuration for the jms component, I have the following:
(the xyJndiTemplate is a customer class that will not only set JNDI
properties but some system properties required for the JMS connection -
right now, values are hardcoded)
/********** xbean config
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
       xmlns:b="http://servicemix.apache.org/samples/vc1">

<classpath>
	<location>lib/jbossall-client-4.0.2.GA.jar</location>
	<location>lib/xy-common-1.0-SNAPSHOT.jar</location>
</classpath>

<jms:endpoint service="b:MyConsumerService"
              endpoint="jms"
              targetService="b:pipeline"
              targetEndpoint="myConsumer"
              role="consumer" 
              destinationStyle="topic"
             
initialContextFactory="org.jboss.naming.HttpNamingContextFactory"
              jndiProviderURL="http://192.168.5.5:8881/invoker/JNDIFactory"
              jndiDestinationName="topic/MyTopicName"
              jndiConnectionFactoryName="ConnectionFactory"
              defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
              defaultOperation="test:Echo"
              needJavaIdentifiers="false" />                



<bean id="props" autowire="no"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location" value="C:\temp\xy_launch.properties"/>
		<property name="systemPropertiesModeName"
value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
	</bean>

   <bean id="xyJndiTemplate" class="com.xy.common.util.JndiTemplate">

   		<constructor-arg>
   			<props>
				<prop
key="java.naming.factory.initial">org.jboss.naming.HttpNamingContextFactory</prop>
				<prop
key="java.naming.provider.url">http://192.168.5.5:8881/invoker/JNDIFactory</prop>
				<prop
key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
   			</props>   			
   		</constructor-arg>
   		<property name="systemProperties">
   			<props>
				<prop
key="xy.ejb_invoker_servlet_path">http://192.168.5.5:8881/invoker/EJBInvokerServlet</prop>
				<prop
key="xy.jmx_invoker_servlet_path">http://192.168.5.5:8881/invoker/JMXInvokerServlet</prop>
				<prop
key="java.security.auth.login.config">C:\temp\jms_test\auth.conf</prop>
   			</props>   			
   		</property>
   	</bean>
***************** end xbean config ***********/

The problem is that there doesn't seem to be anywhere to specify the
username and password used when the connection is created as there is in
code. So I tried somewhat desperately to use the connection factory from
ActiveMQ and set the connection factory in the jms component to use it
(using the #connectionFactory as the value)

  <bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="tcp://localhost:61616" />
    <property name="userName" value="xyUser" />
    <property name="password" value="xyPass" />
  </bean>
              
But that just seemed give me a local connection out of the pool, which isn't
what I needed. I needed to get a connection from the factory on the other
JMS server.

Anyway, I'm trying to accomplish using the component what we do in the code
example but can't seem to figure it out. I'm pretty sure the issue is the
username and password on the connection because when I deploy the component,
the error message is that "not authorized to subscribe to topic
MyTopicName". All the other connection issues seem to work as I have
resolved them one by one.

Any insight would be greatly appreciated.
-- 
View this message in context: http://www.nabble.com/JMS-consumer-issue-tf4957536s12049.html#a14197444
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: JMS consumer issue

Posted by jeff1331 <jg...@voyence.com>.
Ok, will do Bruce, thanks for the help.


bsnyder wrote:
> 
> On Dec 6, 2007 2:09 PM, jeff1331 <jg...@voyence.com> wrote:
> 
>> So, to answer your question, the topic is hosted on some jboss server on
>> another box. This servicemix jms component needs to connect to it, stay
>> connected, and receive all the messages coming out of it.
> 
> OK, that last sentence is what I needed to know. It should be pretty
> easy to connect directly to JBossMQ using the JBossMQ connection
> factory. See this FAQ entry about connecting to WebsphereMQ as an
> example:
> 
> http://servicemix.apache.org/how-do-i-integrate-the-servicemix-jms-component-with-webspheremq.html
> 
> Just use the connection factory for JBossMQ in the same manner. And
> once you figure this out, please help us create an FAQ entry for
> JBossMQ.
> 
> Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> Apache ActiveMQ - http://activemq.org/
> Apache Camel - http://activemq.org/camel/
> Apache ServiceMix - http://servicemix.org/
> Apache Geronimo - http://geronimo.apache.org/
> 
> Blog: http://bruceblog.org/
> 
> 

-- 
View this message in context: http://www.nabble.com/JMS-consumer-issue-tf4957536s12049.html#a14202384
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: JMS consumer issue

Posted by Bruce Snyder <br...@gmail.com>.
On Dec 6, 2007 2:09 PM, jeff1331 <jg...@voyence.com> wrote:

> So, to answer your question, the topic is hosted on some jboss server on
> another box. This servicemix jms component needs to connect to it, stay
> connected, and receive all the messages coming out of it.

OK, that last sentence is what I needed to know. It should be pretty
easy to connect directly to JBossMQ using the JBossMQ connection
factory. See this FAQ entry about connecting to WebsphereMQ as an
example:

http://servicemix.apache.org/how-do-i-integrate-the-servicemix-jms-component-with-webspheremq.html

Just use the connection factory for JBossMQ in the same manner. And
once you figure this out, please help us create an FAQ entry for
JBossMQ.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/

Blog: http://bruceblog.org/

Re: JMS consumer issue

Posted by jeff1331 <jg...@voyence.com>.
>
> The problem is that there doesn't seem to be anywhere to specify the
> username and password used when the connection is created as there is in
> code. So I tried somewhat desperately to use the connection factory from
> ActiveMQ and set the connection factory in the jms component to use it
> (using the #connectionFactory as the value)
>
>   <bean id="connectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>     <property name="brokerURL" value="tcp://localhost:61616" />
>     <property name="userName" value="xyUser" />
>     <property name="password" value="xyPass" />
>   </bean>
>
> But that just seemed give me a local connection out of the pool, which
> isn't
> what I needed. I needed to get a connection from the factory on the other
> JMS server.

What you've done above to specify the username/password on the
connectionFactory is correct, but I'm not sure what you mean be 'the
other JMS server'? Is there more than one ActiveMQ broker being used?
Please clarify this further.

Bruce
-- 

What we have is a JBoss server which has a JMS topic that is used by
external programs to get events coming from the server. The java code you
saw earlier was an example of a simple java client that receives messages
from this server. That JMS client code starts the topic connection then sets
itself up as the topic listener - to add to the previously posted code,
there is an onMessage() method that is called whenever the message is
received -

/***** java client to JMS topic
TopicConnection topicConnection = factory.createTopicConnection("xyUser",
"xyPass");

TopicSession topicSession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
TopicSubscriber topicSubscriber = topicSession.createSubscriber(eventTopic);
System.out.println("Connected to topic.");
topicSubscriber.setMessageListener(this);

    public void onMessage(Message message)
    {
        try
        {
            TextMessage textMessage = (TextMessage) message;
	String eventXml = textMessage.getText();
            ......
****** end java code */

If I fire up this client, then look in the JMX console of the JBoss server
and look at the topic, I will see a connection. 

When using the connection broker with the username and password set, there
are no error messages. However, I see no connections to the JMS topic using
the JMX console in the Jboss server.

This tells me one of two things -
1. the servicemix-jms component never connected. OR
2. The component connected, checked for messages, then disconnected.

So, to answer your question, the topic is hosted on some jboss server on
another box. This servicemix jms component needs to connect to it, stay
connected, and receive all the messages coming out of it.


-- 
View this message in context: http://www.nabble.com/JMS-consumer-issue-tf4957536s12049.html#a14201051
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: JMS consumer issue

Posted by Bruce Snyder <br...@gmail.com>.
On Dec 6, 2007 10:46 AM, jeff1331 <jg...@voyence.com> wrote:
>
> Ok, I've given this a whirl for a few days, would appreciate some help. We
> have a JMS topic publishing events and I want to connect to it via service
> mix. I've been attempting to use the servicemix-jms component.
>
> I've worked through most of the issues but there is one hurdle I can't seem
> to get over. The topic requires a username and password when the connection
> is created. In code, it looks like this:
>
> /*********** java code
> TopicConnectionFactory factory = (TopicConnectionFactory)
> ctx.lookup("ConnectionFactory");
> Topic eventTopic = (Topic) ctx.lookup(topicName);
> System.out.println("Found JMS topic.");
>
> TopicConnection topicConnection = factory.createTopicConnection("xyzUser",
> "xyzPass");
>
> TopicSession topicSession = topicConnection.createTopicSession(false,
> Session.AUTO_ACKNOWLEDGE);
> TopicSubscriber topicSubscriber = topicSession.createSubscriber(eventTopic);
> System.out.println("Connected to topic.");
> topicSubscriber.setMessageListener(this);
> ********** end java code */
>
> Notice the factory.createTopicConnection() method taking the username and
> password.
>
> In my xbean.xml configuration for the jms component, I have the following:
> (the xyJndiTemplate is a customer class that will not only set JNDI
> properties but some system properties required for the JMS connection -
> right now, values are hardcoded)
> /********** xbean config
> <beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
>        xmlns:b="http://servicemix.apache.org/samples/vc1">
>
> <classpath>
>         <location>lib/jbossall-client-4.0.2.GA.jar</location>
>         <location>lib/xy-common-1.0-SNAPSHOT.jar</location>
> </classpath>
>
> <jms:endpoint service="b:MyConsumerService"
>               endpoint="jms"
>               targetService="b:pipeline"
>               targetEndpoint="myConsumer"
>               role="consumer"
>               destinationStyle="topic"
>
> initialContextFactory="org.jboss.naming.HttpNamingContextFactory"
>               jndiProviderURL="http://192.168.5.5:8881/invoker/JNDIFactory"
>               jndiDestinationName="topic/MyTopicName"
>               jndiConnectionFactoryName="ConnectionFactory"
>               defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>               defaultOperation="test:Echo"
>               needJavaIdentifiers="false" />
>
>
>
> <bean id="props" autowire="no"
> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
>                 <property name="location" value="C:\temp\xy_launch.properties"/>
>                 <property name="systemPropertiesModeName"
> value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
>         </bean>
>
>    <bean id="xyJndiTemplate" class="com.xy.common.util.JndiTemplate">
>
>                 <constructor-arg>
>                         <props>
>                                 <prop
> key="java.naming.factory.initial">org.jboss.naming.HttpNamingContextFactory</prop>
>                                 <prop
> key="java.naming.provider.url">http://192.168.5.5:8881/invoker/JNDIFactory</prop>
>                                 <prop
> key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
>                         </props>
>                 </constructor-arg>
>                 <property name="systemProperties">
>                         <props>
>                                 <prop
> key="xy.ejb_invoker_servlet_path">http://192.168.5.5:8881/invoker/EJBInvokerServlet</prop>
>                                 <prop
> key="xy.jmx_invoker_servlet_path">http://192.168.5.5:8881/invoker/JMXInvokerServlet</prop>
>                                 <prop
> key="java.security.auth.login.config">C:\temp\jms_test\auth.conf</prop>
>                         </props>
>                 </property>
>         </bean>
> ***************** end xbean config ***********/
>
> The problem is that there doesn't seem to be anywhere to specify the
> username and password used when the connection is created as there is in
> code. So I tried somewhat desperately to use the connection factory from
> ActiveMQ and set the connection factory in the jms component to use it
> (using the #connectionFactory as the value)
>
>   <bean id="connectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>     <property name="brokerURL" value="tcp://localhost:61616" />
>     <property name="userName" value="xyUser" />
>     <property name="password" value="xyPass" />
>   </bean>
>
> But that just seemed give me a local connection out of the pool, which isn't
> what I needed. I needed to get a connection from the factory on the other
> JMS server.

What you've done above to specify the username/password on the
connectionFactory is correct, but I'm not sure what you mean be 'the
other JMS server'? Is there more than one ActiveMQ broker being used?
Please clarify this further.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/

Blog: http://bruceblog.org/