The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » GlassFish

Thread: create UDP server with glassfish/ejb

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 7 - Last Post: Sep 17, 2007 12:44 PM by: bbergquist
cyvan

Posts: 9
create UDP server with glassfish/ejb
Posted: Aug 29, 2007 3:41 PM
  Click to reply to this thread Reply

Hi,
I have a mobile application that's using GPRS to send UDP messages to an IP address - wast amount of ~1K text messages every second.
I want to create a UDP server app using the JAVA EE technology.After getting the messages over UDP, I would like to convert them to JMS messages and place them in a queue for message-driven beans to pick them up one by one.
Now, I'm not sure if I can do this with Glassfish .
Can I somehow open a UDP port and listen for messages ?
Or should I rather make a Java SE app which receives messages from client and passes them into the application server message queue?

Thanks a lot !!

Ivan

Daniel H. Caval...
Re: create UDP server with glassfish/ejb
Posted: Aug 30, 2007 6:10 AM   in response to: cyvan
  Click to reply to this thread Reply

If you'd like to perform this inside GlassFish, I think you could do it
with Lifecycle modules, which gets started and shutdown with glassfish
and runs in its context, so you could send JMS messages.
Or you could do just as you suggested, as a standalone program.

glassfish@javadesktop.org wrote:
> Hi,
> I have a mobile application that's using GPRS to send UDP messages to an IP address - wast amount of ~1K text messages every second.
> I want to create a UDP server app using the JAVA EE technology.After getting the messages over UDP, I would like to convert them to JMS messages and place them in a queue for message-driven beans to pick them up one by one.
> Now, I'm not sure if I can do this with Glassfish .
> Can I somehow open a UDP port and listen for messages ?
> Or should I rather make a Java SE app which receives messages from client and passes them into the application server message queue?
>
> Thanks a lot !!
>
> Ivan
> [Message sent by forum member 'cyvan' (cyvan)]
>
> http://forums.java.net/jive/thread.jspa?messageID=233179
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net


tjquinn

Posts: 618
Re: create UDP server with glassfish/ejb
Posted: Aug 30, 2007 7:05 AM   in response to: cyvan
  Click to reply to this thread Reply

Have you considered building a connector following the connector architecture? That would allow you to build the solution entirely within the app server and avoid the separate stand-alone program. That could be a very good fit for your situation.

- Tim

Jeanfrancois Ar...
Re: create UDP server with glassfish/ejb
Posted: Aug 30, 2007 7:31 AM   in response to: tjquinn
  Click to reply to this thread Reply



glassfish@javadesktop.org wrote:
> Have you considered building a connector following the connector architecture? That would allow you to build the solution entirely within the app server and avoid the separate stand-alone program. That could be a very good fit for your situation.
>

...and for a cool NIO based UDP framework, you might want to look at [1]
or [2]. I prefer [1] ;-), but [2] is quite good as well :-)

-- Jeanfrancois

[1] http://grizzly.dev.java.net
[2] http://mina.apache.org



> - Tim
> [Message sent by forum member 'tjquinn' (tjquinn)]
>
> http://forums.java.net/jive/thread.jspa?messageID=233278
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net


cyvan

Posts: 9
Re: create UDP server with glassfish/ejb
Posted: Aug 31, 2007 5:48 PM   in response to: tjquinn
  Click to reply to this thread Reply

OK,
thank you all very much for your help.

Now, using j2ee connector architecture sounds cool, but I really have no idea how to use it in this case. I read several jca explanations, but I still can't figure out how I could use it.

Can you give me some hints ?
Thanks a lot !

Ivan

sivakumart

Posts: 55
Re: create UDP server with glassfish/ejb
Posted: Sep 6, 2007 3:46 AM   in response to: cyvan
  Click to reply to this thread Reply

Hi

> Now, using j2ee connector architecture sounds cool,
> but I really have no idea how to use it in this case.
> I read several jca explanations, but I still can't
> figure out how I could use it.

There are many J2EE connector tutorials to get started. The following resources might help you get started..

A tutorial on creating a new resource adapter
http://developers.sun.com/appserver/reference/techart/resource_adapters.pdf

A presentation we did at JavaOne 2005 on building resource adapters
http://gceclub.sun.com.cn/java_one_online/2005/TS-3513/ts-3513.pdf

The connectors section of the Java EE tutorial
http://java.sun.com/javaee/5/docs/tutorial/doc/Connector.html#wp79662

A bunch of interesting articles are also listed at
http://www.java201.com/resources/browse/2005/jca_1.5.html

Please post to this forum should you need more information.

Thanks
--Siva

cyvan

Posts: 9
Re: create UDP server with glassfish/ejb
Posted: Sep 14, 2007 5:07 PM   in response to: sivakumart
  Click to reply to this thread Reply

Hi, thanks for the links.

I read a lot about JCA since my last post.
I found that it shouldn't be so hard to implement an adapter for incoming messages in this case.
I have some issues I couldn't sort out yet, though.

I want to make a resource adapter that opens a socket and listens for messages, than makes a Work object and passes it, with the fetched message, to the app server. When processed, the Work should pass the message to the JMS Queue.
My problem is that I'm not sure how I can get a reference to the JMS Queue into the Work object. The Work is not executed in a container, so I cannot inject a Queue with annotation. I'd rather pass the message to the Queue than use resource adapter's createEndpoint method, and call the onMessage method directly. This way I can make use of app server's MDB pooling capabilities.

Thanks a lot,

Ivan

bbergquist

Posts: 108
Re: create UDP server with glassfish/ejb
Posted: Sep 17, 2007 12:44 PM   in response to: cyvan
  Click to reply to this thread Reply

You really cannot access the any JNDI resources inside of the connector directly. The JCA spec mentions that a connector has no JNDI context except in the calling thread of an outbound connection and in the MDB in an inbound connection.

I just did something similar. I created a JCA that has an inbound connector. I have a service that I started and run inside the connector using the WorkManager and Work items. I defined a listener interface and then wrote an MDB the implemented that interface. When I receive a UDP message, I pass the UDP data to the MDB endpoint. Inside the MDB implementation, you do have access to all of the J2EE facilities so inside here, you could post the a message to a JMS queue or topic. Inside the MDB, you can use annotations to get a hold of the JMS resource that you need (ie. connection factory, queue, etc.).




 XML java.net RSS