Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [NET4J]
[NET4J] [message #94676] Tue, 28 August 2007 08:59 Go to next message
Eclipse UserFriend
Hi Eike,

You have a projects about JMS in net4j.. Can you give me some details ?

What it does exactly ?
Re: [NET4J] [message #94691 is a reply to message #94676] Tue, 28 August 2007 11:32 Go to previous message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

Hi Simon,

It is an experimental implemenation of the JMS specification on top of
Net4j.
It is basically working but not complete. If I recall correctly the
persistence layer is not implemented. With the newer experience of the
CDO IStore layer I would eventually change the JMS IStore.
Some of the non-critical elements of the JMS spec are missing or are
ignored: TTL, priority, ...

There's a simple test case in JMSTest.java:

public class JMSTest
{
public static void main(String[] args) throws Exception
{
try
{
Context context = init();
ConnectionFactory connectionFactory =
(ConnectionFactory)context.lookup("net4j.jms.ConnectionFactory ");
Destination destination = (Destination)context.lookup("StockTopic");

Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(true, 0);

MessageProducer publisher = session.createProducer(destination);
MessageConsumer subscriber1 = session.createConsumer(destination);
MessageConsumer subscriber2 = session.createConsumer(destination);
subscriber1.setMessageListener(new MessageLogger("subscriber1"));
subscriber2.setMessageListener(new MessageLogger("subscriber2"));

connection.start();

publisher.send(session.createObjectMessage("Message 1"));
publisher.send(session.createObjectMessage("Message 2"));
publisher.send(session.createObjectMessage("Message 3"));
publisher.send(session.createObjectMessage("Message 4"));

session.commit();
}
finally
{
Thread.sleep(500);
Server.INSTANCE.deactivate();
}
}

private static Context init() throws Exception
{
OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOL E);
OMPlatform.INSTANCE.setDebugging(true);

IDBAdapter.REGISTRY.put("derby", new DerbyAdapter());
IStore store = JDBCUtil.getStore();
Server.INSTANCE.setStore(store);
Server.INSTANCE.activate();

IManagedContainer container = new ManagedContainer();
Net4jUtil.prepareContainer(container);
TCPUtil.prepareContainer(container);
JMSUtil.prepareContainer(container);
JMSServerUtil.prepareContainer(container);
JMSAdminUtil.prepareContainer(container);

TCPAcceptorFactory.get(container, null);
IConnector connector = TCPConnectorFactory.get(container, "localhost");

IJMSAdmin admin = JMSAdminUtil.createAdmin(connector);
admin.createQueue("StockQueue");
admin.createTopic("StockTopic");

return new JMSInitialContext(container);
}

/**
* @author Eike Stepper
*/
private static final class MessageLogger implements MessageListener
{
private String name;

public MessageLogger(String name)
{
this.name = name;
}

public void onMessage(Message message)
{
try
{
Object object = ((ObjectMessage)message).getObject();
System.out.println("\n------> MESSAGE for " + name + ": " +
object + "\n");
message.acknowledge();
}
catch (JMSException ex)
{
ex.printStackTrace();
}
}
}
}

If you want to give it a try for curiosity there's an external launch
config to start an RMIRegistry.
Although my implementation of JMS also comes with a proprietary API for
managing JMS administrative objects (queues and topics) the standard way
is using JNDI for this purpose.
The test case uses my IJMSAdmin to create a queue and a topic (and
register them in RMIRegistry). JNDI is used to pull them from the
RMIRegistry and use them.

Cheers
/Eike


Simon McDuff schrieb:
> Hi Eike,
>
> You have a projects about JMS in net4j.. Can you give me some details ?
>
> What it does exactly ?
>
>
>
Re: [NET4J] [message #609568 is a reply to message #94676] Tue, 28 August 2007 11:32 Go to previous message
Eclipse UserFriend
Hi Simon,

It is an experimental implemenation of the JMS specification on top of
Net4j.
It is basically working but not complete. If I recall correctly the
persistence layer is not implemented. With the newer experience of the
CDO IStore layer I would eventually change the JMS IStore.
Some of the non-critical elements of the JMS spec are missing or are
ignored: TTL, priority, ...

There's a simple test case in JMSTest.java:

public class JMSTest
{
public static void main(String[] args) throws Exception
{
try
{
Context context = init();
ConnectionFactory connectionFactory =
(ConnectionFactory)context.lookup("net4j.jms.ConnectionFactory ");
Destination destination = (Destination)context.lookup("StockTopic");

Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(true, 0);

MessageProducer publisher = session.createProducer(destination);
MessageConsumer subscriber1 = session.createConsumer(destination);
MessageConsumer subscriber2 = session.createConsumer(destination);
subscriber1.setMessageListener(new MessageLogger("subscriber1"));
subscriber2.setMessageListener(new MessageLogger("subscriber2"));

connection.start();

publisher.send(session.createObjectMessage("Message 1"));
publisher.send(session.createObjectMessage("Message 2"));
publisher.send(session.createObjectMessage("Message 3"));
publisher.send(session.createObjectMessage("Message 4"));

session.commit();
}
finally
{
Thread.sleep(500);
Server.INSTANCE.deactivate();
}
}

private static Context init() throws Exception
{
OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOL E);
OMPlatform.INSTANCE.setDebugging(true);

IDBAdapter.REGISTRY.put("derby", new DerbyAdapter());
IStore store = JDBCUtil.getStore();
Server.INSTANCE.setStore(store);
Server.INSTANCE.activate();

IManagedContainer container = new ManagedContainer();
Net4jUtil.prepareContainer(container);
TCPUtil.prepareContainer(container);
JMSUtil.prepareContainer(container);
JMSServerUtil.prepareContainer(container);
JMSAdminUtil.prepareContainer(container);

TCPAcceptorFactory.get(container, null);
IConnector connector = TCPConnectorFactory.get(container, "localhost");

IJMSAdmin admin = JMSAdminUtil.createAdmin(connector);
admin.createQueue("StockQueue");
admin.createTopic("StockTopic");

return new JMSInitialContext(container);
}

/**
* @author Eike Stepper
*/
private static final class MessageLogger implements MessageListener
{
private String name;

public MessageLogger(String name)
{
this.name = name;
}

public void onMessage(Message message)
{
try
{
Object object = ((ObjectMessage)message).getObject();
System.out.println("\n------> MESSAGE for " + name + ": " +
object + "\n");
message.acknowledge();
}
catch (JMSException ex)
{
ex.printStackTrace();
}
}
}
}

If you want to give it a try for curiosity there's an external launch
config to start an RMIRegistry.
Although my implementation of JMS also comes with a proprietary API for
managing JMS administrative objects (queues and topics) the standard way
is using JNDI for this purpose.
The test case uses my IJMSAdmin to create a queue and a topic (and
register them in RMIRegistry). JNDI is used to pull them from the
RMIRegistry and use them.

Cheers
/Eike


Simon McDuff schrieb:
> Hi Eike,
>
> You have a projects about JMS in net4j.. Can you give me some details ?
>
> What it does exactly ?
>
>
>
Previous Topic:[NET4J]
Next Topic:Problem using generated hibernate mapping file
Goto Forum:
  


Current Time: Tue Apr 29 02:36:49 EDT 2025

Powered by FUDForum. Page generated in 0.30259 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top