If anybody is interested - here is the working code:
| /**
| * @ejb.bean
| * name="LogMessageService"
| * jndi-name="LogMessageService"
| * type="Stateless"
| * view-type="remote"
| *
| * @ejb.transaction type="Required"
| *
| * @ejb.permission
| * role-name = "Authenticated"
| *
| * @ejb.resource-ref res-ref-name = "jms/TopicConnectionFactory" res-type =
"javax.jms.TopicConnectionFactory" res-auth = "Container"
| * @jboss.resource-ref res-ref-name = "jms/TopicConnectionFactory" jndi-name =
"java:/JmsXA"
| *
| * @ejb.resource-env-ref name = "MyTopic" type = "javax.jms.Topic"
| * @jboss.resource-env-ref resource-env-ref-name = "MyTopic" jndi-name =
"topic/MyTopic"
| */
| public class LogMessageServiceEJB extends AbstractServiceEJB implements
SessionBean {
|
| /**
| * @ejb.create-method
| */
| public void ejbCreate() throws javax.ejb.CreateException {
| }
|
| /**
| * @ejb.interface-method
| */
| public void sendMessage( String text) throws RemoteException {
| System.out.println("LogMessageServiceEJB.sendMessage(): text="+text);
| TopicConnection topicConnection = null;
| TopicSession topicSession = null;
| try {
| Context initialContext = new InitialContext();
| TopicConnectionFactory f = ( TopicConnectionFactory ) initialContext.lookup(
"java:comp/env/jms/TopicConnectionFactory" );
| Topic myTopic = ( Topic ) initialContext.lookup( "java:comp/env/MyTopic" );
|
|
| topicConnection = f.createTopicConnection();
| topicSession = topicConnection.createTopicSession( false, 0);
|
| TopicPublisher topicPublisher = topicSession.createPublisher( myTopic );
|
| TextMessage message = topicSession.createTextMessage( text);
| topicPublisher.publish( message);
|
|
| } catch ( NamingException ex ) {
| throw new EJBException( ex );
| } catch ( JMSException ex ) {
| throw new EJBException( ex );
| } finally {
| try {
| if ( topicSession != null ) {
| topicSession.close();
| }
| } catch ( JMSException ex1 ) {
| System.err.println( ex1.getMessage());
| ex1.printStackTrace();
| }
| try {
| if ( topicConnection != null ) {
| topicConnection.close();
| }
| } catch ( JMSException ex1 ) {
| System.err.println( ex1.getMessage());
| ex1.printStackTrace();
| }
| }
| }
|
| }
|
Boo.
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3841544#3841544
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3841544
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user