You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Sule BASOL <ka...@icloud.com> on 2013/02/13 08:48:35 UTC
Remote access openejb from swing app and get notification possible?
Hello , I want to access openejb remotely from my swing application.
Like;
final Properties prop = new Properties( );
prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
prop.put(Context.PROVIDER_URL, "multipulse://239.255.2.3:6142?group=default&timeout=250");
final InitialContext c = new InitialContext(prop);
this connects to openejb server great.
But i want to send notifications to many swing clients.
I heard about activemq , but i cant access activemq directly from openejb connection 'c' object.
I need to make new connection to activemq as shown below ;
final Hashtable<String, String> ctxProps = new Hashtable<String, String>(2);
ctxProps.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
ctxProps.put("java.naming.provider.url", "tcp://localhost:61616");
return new InitialContext(ctxProps);
But , this makes some problems i think.
I need double authentication and different servers for only getting notifications ?
it seems so stupid to only get notification requires double connection to different servers?
Why i cant directly get notifications from openejb server?
I will make poll every second to get notification ?
Currently i get notification from activemq like this ;
final Topic topic = (Topic) activeMQInitialContext.lookup( "dynamicTopics/test1" );
final TopicConnectionFactory factory1 = (TopicConnectionFactory) activeMQInitialContext.lookup("TopicConnectionFactory");
final TopicConnection topicConnection = factory1.createTopicConnection();
TopicSession subSession = topicConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
// Look up a JMS topic
TopicSubscriber subscriber = subSession.createSubscriber( topic );
//listen for notifications.
subscriber.setMessageListener(this);
connection.start();
But i want to get notification from openejb connection directly.
I want to make single connection.
Possible ?
separate connections makes problem like ;
double authentication and no dependency between openejb and activemq becomes more complex and slow.
Please help ;(