Jason,
Why not to think about an EJB as a plain client
for JMS? There is nothing special here.
I have a helper class (sort of ServiceLocator pattern)
which I'm using either on clients (servlets) and server (EJBs):
/************************************************************
* creates query session
************************************************************/
private void getQueueSession() throws BmxServerException
{
if ( qsession != null )
return;
// !!!provider specific!!!, must be got from properties
QueueConnectionFactory queueFactory = null;
try
{
queueFactory =
(QueueConnectionFactory)context.lookup("QueueConnectionFactory");
}
catch (NamingException ne)
{
throw new BmxServerException(ne, BmxError.InternalError);
}
try
{
QueueConnection queueConnection =
queueFactory.createQueueConnection();
qsession = queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
}
catch (JMSException jmse)
{
throw new BmxServerException(jmse, BmxError.InternalError);
}
}
/************************************************************
* sends message into queue
************************************************************/
public void sendXmlMessage(String queueName, XmlDescriptor xmessage)
throws BmxServerException
{
getQueueSession();
try
{
Queue queue = (Queue)context.lookup("queue/" +
queueName);
QueueSender sender = qsession.createSender(queue);
TextMessage tmess = qsession.createTextMessage();
tmess.setText(xmessage.toXmlString());
sender.send(tmess);
}
catch (Exception e)
{
throw new BmxServerException(e, BmxError.InternalError);
}
}
Jason Dillon wrote:
>
> Can someone point me a documentation or examples on the standard way to
> allow a EJB to access an external resource.
>
> I looked at the EJB spec and it was less than helpful. I saw one example
> of letting a bean access a JMS queue, but what about the ConnectionFactory
> and such? Do I need to have a seperate entry for that too?
>
> Is anyone using MDB who can give me some advise on how to go about letting
> an EJB access a JMS queue or topic?
>
> Thanks,
>
> --jason
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
--
__________________________________________________
Alexander Kogan PTC www.ptc.com
[EMAIL PROTECTED] 140 Kendrick St. Needham MA 02494
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user