You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by guenther <GM...@fugro.be> on 2013/10/21 10:32:05 UTC

AMQP_1.0 activemq server side context.xml configuration spring

Hi, 

I'm trying to implement the Hello-example, but would like to use Spring with
Tomcat on the server side. Currently I have an application.xml (which I
successfully used for activemq and tcp) with a JNDI-reference to a
context.xml which looks like this:

<Context reloadable="true">
	<Resource auth="Container"
	   name="jms/ConnectionFactory"
	   type="org.apache.activemq.ActiveMQConnectionFactory"
	   description="JMS Connection Factory"
	   factory="org.apache.activemq.jndi.JNDIReferenceFactory"
	   brokerURL="vm:broker:(tcp://127.0.0.1:6000)?persistent=false"/>
</Context>

So what would I have to change here to make this work with AMQP_1.0.?

Thanks, 
Günther 



--
View this message in context: http://qpid.2158936.n2.nabble.com/AMQP-1-0-activemq-server-side-context-xml-configuration-spring-tp7599690.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: AMQP_1.0 activemq server side context.xml configuration spring

Posted by Gordon Sim <gs...@redhat.com>.
On 10/24/2013 04:25 PM, guenther wrote:
> Hi Gordon,
>
> regarding my "businessRequestQueue" the issue was that when I just put that
> name into the properties file
> the way you mention:
>
> queue.topicExchange=businessRequestQueue
>
> and let the queue be generated "automatically" by the
> org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory (this
> is the 1.0-version of the Factory in the example) keeping the example-code
>
> Destination destination = (Destination) context.lookup("topicExchange");
>
> I got a DestinationImpl as the destination and not a QueueImpl and this
> somehow led to an exception when I tried to send the message. Actually I
> don't know why this happened.

Ah, sorry, I didn't realise you had already tried that. I'm not sure 
what the issue is there. Rob or anyone else, are you able to shed any light?

> But as soon I ignored the properties file for
> the creation of the destination and used in a "hardcoded" way (in the sense
> that it didn't use the Factory for the creation)
>
> Destination destination = session.createQueue("businessRequestQueue");
>
> it worked.
>
> Regarding JIRA: someone from the Qpid team should say, if there's any
> purpose behind not having a default constructor any more for the connection
> factory.

My guess would be that its absence did not previously cause any 
problems. The destination and connection factory impls for the old 
0-10/0-9-1/0.8 client do all have default destructors.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: AMQP_1.0 activemq server side context.xml configuration spring

Posted by guenther <GM...@fugro.be>.
Hi Gordon, 

regarding my "businessRequestQueue" the issue was that when I just put that
name into the properties file
the way you mention: 

queue.topicExchange=businessRequestQueue

and let the queue be generated "automatically" by the
org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory (this
is the 1.0-version of the Factory in the example) keeping the example-code

Destination destination = (Destination) context.lookup("topicExchange");

I got a DestinationImpl as the destination and not a QueueImpl and this
somehow led to an exception when I tried to send the message. Actually I
don't know why this happened. But as soon I ignored the properties file for
the creation of the destination and used in a "hardcoded" way (in the sense
that it didn't use the Factory for the creation)

Destination destination = session.createQueue("businessRequestQueue");

it worked. 

Regarding JIRA: someone from the Qpid team should say, if there's any
purpose behind not having a default constructor any more for the connection
factory. 

Kind Regards, 
Günther

 






--
View this message in context: http://qpid.2158936.n2.nabble.com/AMQP-1-0-activemq-server-side-context-xml-configuration-spring-tp7599690p7599891.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: AMQP_1.0 activemq server side context.xml configuration spring

Posted by Gordon Sim <gs...@redhat.com>.
On 10/23/2013 11:16 AM, guenther wrote:
> To answer my own question, this is how I made the "Hello World" example work
> in my environment:

Thanks very much for posting back your findings! It will help me and 
others that have yet to get familiar with this particular client.

> On the client side, the main problem was the destination which in the
> original code goes like this:
>
> Destination destination = (Destination) context.lookup("topicExchange");
>
> This actually will create a DestinationImpl - object.
>
> I had to change this to
> Destination destination = session.createQueue("businessRequestQueue");
> to create a QueueImpl instead of a DestinationImpl for my specific
> destination which has the physical name "businessRequestQueue".
> (I didn't know how to make the PropertiesFileInitialContextFactory do this,
> so I "hardcoded" it).

Looking at the 'hello' example, I think (someone please correct me if I 
am wrong) you would have:

   queue.topicExchange=businessRequestQueue

In order to lookup a Queue whose name is 'businessRequestQueue' using 
the lookup key 'topicExchange' (which is a bit of an odd name, so 
perhaps I misunderstood what you are looking for).

> On the server side of my real application (which I used to try out the
> "Hello world") I replaced the context.xml which I mentioned in my question
> by the following:
>
> <Context reloadable="true">
> 	<Resource name="jms/ConnectionFactory" auth="Container"
> 	   type="org.apache.qpid.amqp_1_0.jms.ConnectionFactory"
> 	   description="JMS Connection Factory"
>         factory="com.fugro.gwf.server.jmssender.AMQFactory"
> 	   brokerURL="vm:broker:(amqp://127.0.0.1:5672)?persistent=false"/>
> </Context>
>
> This uses a custom JNDI factory named AMQFactory (because there is not
> default constructor in
> org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl)

That sounds like something that could get fixed if you want to raise a JIRA.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: AMQP_1.0 activemq server side context.xml configuration spring

Posted by guenther <GM...@fugro.be>.
To answer my own question, this is how I made the "Hello World" example work
in my environment:

On the client side, the main problem was the destination which in the
original code goes like this:

Destination destination = (Destination) context.lookup("topicExchange");

This actually will create a DestinationImpl - object. 

I had to change this to 
Destination destination = session.createQueue("businessRequestQueue");
to create a QueueImpl instead of a DestinationImpl for my specific
destination which has the physical name "businessRequestQueue". 
(I didn't know how to make the PropertiesFileInitialContextFactory do this,
so I "hardcoded" it).

On the server side of my real application (which I used to try out the
"Hello world") I replaced the context.xml which I mentioned in my question
by the following: 

<Context reloadable="true">
	<Resource name="jms/ConnectionFactory" auth="Container"
	   type="org.apache.qpid.amqp_1_0.jms.ConnectionFactory"
	   description="JMS Connection Factory"
       factory="com.fugro.gwf.server.jmssender.AMQFactory"
	   brokerURL="vm:broker:(amqp://127.0.0.1:5672)?persistent=false"/>
</Context>

This uses a custom JNDI factory named AMQFactory (because there is not
default constructor in 
org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl) whose code is the
following: 

public class AMQFactory implements ObjectFactory 
{
	@Override
	public Object getObjectInstance(Object obj, Name name, Context nameCtx,
			Hashtable<?, ?> environment) throws Exception 
	{
		if (name.get(0).equals("ConnectionFactory"))
			return new ConnectionFactoryImpl("localhost", 5672,"", "");
		
		return null;
	}
}

Now everything finally works. 

Any comments about other experiences are welcome!

Günther




--
View this message in context: http://qpid.2158936.n2.nabble.com/AMQP-1-0-activemq-server-side-context-xml-configuration-spring-tp7599690p7599828.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org