[jboss-user] [JBoss Messaging] - Re: Embedded server - how to create JMS Topic?

2009-07-13 Thread Leos.Bitto
"ataylor" wrote : anonymous wrote : Cool, it is nice to see that you guys from 
JBoss are willing to suggest a straight replacement of JBoss Microcontainer by 
Spring Framework
  | 
  | I wouldnt say that, this is just something i was messing round with. 
  | 

Well, I have actually suspected that the omission of JBoss Microcontainer in 
your example would be most probably considered a mistake by most 
RedHat-employed people. :-)

"ataylor" wrote : 
  | anonymous wrote : Your example is missing the JMS objects needed at the 
client side, though - at least javax.jms.(XA)ConnectionFactory and some 
javax.jms.Destination (Queue or Topic) would be needed, unless you want to use 
your core API directly.
  | 
  | These are defined in the jbm-configuration, jbm-jms.xml and jbm-users.xml 
files.

Sure, but that is where the server picks them. I wrote that your example 
(unlike mine) does not show how the client is supposed to reach these objects.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4243251#4243251

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4243251
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Messaging] - Re: Embedded server - how to create JMS Topic?

2009-07-13 Thread Leos.Bitto
"ataylor" wrote : or If you want to run a full standalone server in spring use 
something like the following and make sure the JBM config files are available 
on the classpath
  | 

Cool, it is nice to see that you guys from JBoss are willing to suggest a 
straight replacement of JBoss Microcontainer by Spring Framework. Your example 
is missing the JMS objects needed at the client side, though - at least 
javax.jms.(XA)ConnectionFactory and some javax.jms.Destination (Queue or Topic) 
would be needed, unless you want to use your core API directly.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4243239#4243239

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4243239
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Messaging] - Re: Embedded server - how to create JMS Topic?

2009-07-13 Thread Leos.Bitto
Because I have started this thread about embedding the JBoss Messaging server, 
here is my solution for everybody who would need it:


  | import java.util.HashMap;
  | import java.util.HashSet;
  | import java.util.Map;
  | import java.util.Set;
  | import org.jboss.messaging.core.config.Configuration;
  | import org.jboss.messaging.core.config.TransportConfiguration;
  | import org.jboss.messaging.core.config.impl.ConfigurationImpl;
  | import org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory;
  | import org.jboss.messaging.core.remoting.impl.invm.TransportConstants;
  | import org.jboss.messaging.core.server.Messaging;
  | import org.jboss.messaging.core.server.MessagingServer;
  | import org.jboss.messaging.jms.JBossQueue;
  | import org.jboss.messaging.jms.JBossTopic;
  | import org.jboss.messaging.utils.SimpleString;
  | 
  | public class EmbeddedServer {
  | 
  | private final MessagingServer server;
  | 
  | public EmbeddedServer() {
  | final Set transports = new 
HashSet();
  | transports.add(new 
TransportConfiguration(InVMAcceptorFactory.class.getName()));
  | server = createMessagingServer(transports);
  | }
  | 
  | public EmbeddedServer(int serverID) {
  | final Map params = new HashMap();
  | params.put(TransportConstants.SERVER_ID_PROP_NAME, serverID);
  | final Set transports = new 
HashSet();
  | transports.add(new 
TransportConfiguration(InVMAcceptorFactory.class.getName(), params));
  | server = createMessagingServer(transports);
  | }
  | 
  | public static MessagingServer 
createMessagingServer(Set transports) {
  | final Configuration configuration = new ConfigurationImpl();
  | configuration.setPersistenceEnabled(false);
  | configuration.setSecurityEnabled(false);
  | configuration.setAcceptorConfigurations(transports);
  | return Messaging.newMessagingServer(configuration);
  | }
  | 
  | public void start() throws Exception {
  | server.start();
  | }
  | 
  | public void stop() throws Exception {
  | server.stop();
  | }
  | 
  | public JBossQueue createQueue(String name, boolean temporary) throws 
Exception {
  | final SimpleString q = JBossQueue.createAddressFromName(name);
  | server.createQueue(q, q, null, false, temporary);
  | return new JBossQueue(name);
  | }
  | 
  | public JBossQueue createQueue(String name) throws Exception {
  | return createQueue(name, false);
  | }
  | 
  | public JBossQueue createTemporaryQueue(String name) throws Exception {
  | return createQueue(name, true);
  | }
  | 
  | public JBossTopic createTopic(String name, boolean temporary) throws 
Exception {
  | final SimpleString t = JBossTopic.createAddressFromName(name);
  | server.createQueue(t, t, new SimpleString("__JBMX=-1"), false, 
temporary);
  | return new JBossTopic(name);
  | }
  | 
  | public JBossTopic createTopic(String name) throws Exception {
  | return createTopic(name, false);
  | }
  | 
  | public JBossTopic createTemporaryTopic(String name) throws Exception {
  | return createTopic(name, true);
  | }
  | }
  | 

You need javax.jms.(XA)ConnectionFactory, too:


  | import java.util.HashMap;
  | import java.util.Map;
  | import org.jboss.messaging.core.config.TransportConfiguration;
  | import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
  | import org.jboss.messaging.core.remoting.impl.invm.TransportConstants;
  | import org.jboss.messaging.jms.client.JBossConnectionFactory;
  | 
  | public class InVMConnector {
  | 
  | public static final String DEFAULT_NAME = 
InVMConnectorFactory.class.getName();
  | 
  | public static JBossConnectionFactory createJBossConnectionFactory() {
  | return createJBossConnectionFactory(DEFAULT_NAME);
  | }
  | 
  | public static JBossConnectionFactory 
createJBossConnectionFactory(String className) {
  | final TransportConfiguration transportConfiguration =
  | new TransportConfiguration(className);
  | return new JBossConnectionFactory(transportConfiguration);
  | }
  | 
  | public static JBossConnectionFactory createJBossConnectionFactory(int 
serverID) {
  | return createJBossConnectionFactory(serverID, DEFAULT_NAME);
  | }
  | 
  | public static JBossConnectionFactory createJBossConnectionFactory(int 
serverID, String className) {
  | final Map connectionParams = new 
HashMap();
  | connectionParams.put(TransportConstants.SERVER_ID_PROP_NAME, 
serverID);
  | final TransportConfiguration transportConfiguration =
  | new TransportConfiguration(className, connectionParams);
  | return new JBossConnectionFactory(transportConfiguration);
  | }
  | 
  | }
  | 

These two classes are designed to be 

[jboss-user] [JBoss Messaging] - Re: Embedded server - how to create JMS Topic?

2009-07-13 Thread Leos.Bitto
"rkapur123" wrote : Hi Leos.bitto
  | 
  | I have jboss SOA 4.3 ESB which has Jboss Messaging as messaging provoder.
  | 
  | Using Spring framework's MDP (message driven pojo) - I want to listen on 
"sampleQueue". As per springframework 2.5 guide - MDP is a simple class which 
implements javax.jms.MessageListener onMessage().
  | 

I do not use any support for JMS from Spring, because my trust in their JMS 
code vanished when I found out how terribly inefficient is their JmsTemplate. 
So I have studied the JMS 1.1 specification and wrote the necessarry code 
myself - it was not difficult, and I got a code which performs much better.

"rkapur123" wrote : 
  | I have the class and specified the following in applicationContext.xml file
  | 
  | 
  |   | 
  |   | 
  |   | 
  |   | 
  |   | 
  |   | 
  |   | 
  |   | 
  |   | 
  | 
  | but how should I define "connectionFactory" and "destination" in spring 
context file. 
  | 

There are more possibilities, but the most versatile one seems to be to use 
JNDI - that actually makes your code compatible with most JMS providers, not 
only JBoss Messaging. Check the chapter 5.3. JNDI configuration of the JBoss 
Messaging documentation and use something like this (not tested):


  |   
  | 
  |   org.jnp.interfaces.NamingContextFactory
  |   jnp://myhost:1099
  |   org.jboss.naming:org.jnp.interfaces
  | 
  |   
  | 
  |   
  | 
  | 
  | 
  | 
  |   
  | 
  |   
  | 
  | 
  | 
  | 
  |   
  | 

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4243200#4243200

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4243200
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Messaging] - Re: Embedded server - how to create JMS Topic?

2009-07-01 Thread Leos.Bitto
"timfox" wrote : "Leos.Bitto" wrote : 
  |   | Nice, but what is "session"?
  | 
  | http://java.sun.com/javaee/5/docs/api/javax/jms/Session.html

We are misunderstood in this case. I need to create the topic, which this 
method does not accomplish - let me quote the specification:

Note that this method is not for creating the physical topic. The physical 
creation of topics is an administrative task and is not to be initiated by the 
JMS API. The one exception is the creation of temporary topics, which is 
accomplished with the createTemporaryTopic method. 

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241113#4241113

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4241113
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Messaging] - Re: Embedded server - how to create JMS Topic?

2009-07-01 Thread Leos.Bitto
"ataylor" wrote : also you can use
  | 
  | 
  |   | session.createTopic(topicName);
  |   | 

Nice, but what is "session"?

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241107#4241107

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4241107
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Messaging] - Re: Embedded server - how to create JMS Topic?

2009-07-01 Thread Leos.Bitto
"jmesnil" wrote : 
  | Regarding jbm-jms.xml, it will be picked up if it is in the classpath. 
Could you place it in a separate directory and add it to the classpath of the 
other server instance instead?
  | 

Sure, I could do that. My setup was a bit messy, because I was just 
experimenting with the possibilities which JBoss Messaging provides. The real 
production deployment would be different for sure.

"jmesnil" wrote : 
  | For JNDI, you could pass a no-op Context implementation to 
JMServerManager.setContext() to "disable" JNDI.
  | 

Thanks for the hint.

"jmesnil" wrote : 
  | Do not hesitate to fill JIRA issues for this kind of improvements.
  | 

I will, as soon as I understand JBM a bit more. At this point I have only one 
small improvement to suggest: it the second argument of createQueue and 
createTopic of JMSServerManagerImpl would be null, simply do not register the 
object to JNDI instead of throwing a NullPointerException.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241104#4241104

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4241104
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Messaging] - Re: Embedded server - how to create JMS Topic?

2009-07-01 Thread Leos.Bitto
Hi Tim,

"timfox" wrote : 
  | JMSServerManager is only really used for loading JMS queue, topic and 
connection factory descriptions from jbm-jms.xml into JNDI and also registering 
them with JMX. The JMX call to createTopic in JMSServerManager basically just 
does that. (Actually I think we should rename them to "deployTopic" or 
"bindTopic" or something similar).
  | 

As soon as I was pointed to JMSServerManager I read the source code, suspected 
that I could live without JMSServerManager and it seems that it is really true.

My application uses the ApplicationContext from Spring Framework, so I already 
have an XML configuration file, and it is easy to add few lines there to create 
the necessarry JMS queues and topics, using my simple class which calls your 
core API. The same is true for creating the JMS (XA)ConnectionFactory - no JNDI 
needed.

"timfox" wrote : 
  | If you're not using JNDI and don't need them in JMX then you shouldn't need 
to use it.
  | 

Yes, I do not use JNDI - I feel that for an embedded server JNDI is not 
necessary. I am not sure what do you mean by "in JMX" - the way I create the 
JMS queue and topic I can see them in JMX with all the cool stuff like message 
counts, etc.

"timfox" wrote : 
  | If you're using JMS you should just be able to instantiate the JMS queue 
and topic instances directly on the client side, e.g.
  | 
  | Topic myTopic = new JBossTopic("myTopic");
  | 
  | ... do stuff with the topic.
  | 

Sure, that is documented nicely and I do that.

"timfox" wrote : 
  | Can you tell me if that works?
  | 

No problem, I can send you my sample code if you let me know how - should I 
just paste in into this forum?

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241099#4241099

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4241099
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Messaging] - Re: Embedded server - how to create JMS Topic?

2009-07-01 Thread Leos.Bitto
Thanks a lot for all the quick answers! Navigating me to JMSServerManagerImpl 
was exactly what I needed. I do not like JMSServerManagerImpl much for 
embedding, though, because of two reasons. First is that it somehow 
automagically picks the file jbm-jms.xml, which in my case belongs to a 
different server instance and therefore must not be used. Second is that it 
registers the queues and topics into JNDI (passing null as the secong argument 
to createTopic leads to NullPointerException) and I am trying to avoid JNDI in 
this case. So I have just borrowed a bit of your code from 
JMSServerManagerImpl.java and this works fine for me:

final SimpleString t = JBossTopic.createAddressFromName(name);
server.createQueue(t, t, new SimpleString("__JBMX=-1"), true, false);

It would be nice if you could make the String "__JBMX=-1" available somewhere 
from your code. Maybe just change the private static final field REJECT_FILTER 
in JMSServerManagerImpl from private to public?

Regarding using the core API directly instead of JMS - that is a possibility, 
of course. However, I am trying to stick with JMS, because that makes my code 
compatible with many other messaging implementations, too, instead of binding 
it tightly to JBoss Messaging.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241082#4241082

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4241082
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Messaging] - Embedded server - how to create JMS Topic?

2009-06-30 Thread Leos.Bitto
I am trying to embed JBoss Messaging 2.0 beta to my application which uses JMS 
API. I can easily create JMS Queue this way:

SimpleString q = new SimpleString("jms.queue."+name);
server.createQueue(q, q, null, true, false);

where "server" is MessagingServer which i create this way:

Configuration configuration = new ConfigurationImpl();
configuration.setPersistenceEnabled(false);
configuration.setSecurityEnabled(false);
configuration.setAcceptorConfigurations(transports);
server = Messaging.newMessagingServer(configuration);
server.start();

However, I do not know how to create JMS Topic. Any hint, please?

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4240967#4240967

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4240967
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user