• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Message apparantly not getting to Queue or MDB from Java Client

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am trying to write a message to a queue from a simple Java Client using Weblogic Workshop 8.1. The code runs to completion, yet the Admin console shows no messages or bytes received and there is no output from the message bean showing that it received anything.

The client and an MDB are part of the same application,
but are in different projects. The Server log does not show any glowing errors. My code is shown below as fragments. Any help would be greatly appreciated!!!

Thank you,

Ken

MESSAGE BEAN
/**
* @ejbgen:message-driven
* ejb-name = Synch
* destination-jndi-name="SynchQueue"
* destination-type = javax.jms.Queue
*
*/
public class SynchMDBBean extends GenericMessageDrivenBean implements MessageDrivenBean, MessageListener
{
public void onMessage(Message msg) {
System.out.println("Synch queue got message");
}
}

CLIENT CODE (getInitialContext shown below)
Context ic = getInitialContext("t3://localhost:7001", "weblogic", "weblogic");
//factory = (QueueConnectionFactory) ic.lookup("java:comp/env/jms/QueueConnectionFactory");
factory = (QueueConnectionFactory) ic.lookup("weblogic.jws.jms.QueueConnectionFactory");
queue = (Queue) ic.lookup("SynchQueue");

transaction t = new orders(11111111,"YA","YA","SB","EEE","0001","TA26",1,1,1000,1000,
0,1,"28.23","0","0",1,0,500);

QueueConnection connect = factory.createQueueConnection();
QueueSession session = connect.createQueueSession(true,Session.AUTO_ACKNOWLEDGE);
QueueSender sender = session.createSender(queue);

ObjectMessage message = null;

message = session.createObjectMessage(t);// throws JMSException;
sender.send(message);

static Context getInitialContext(String url, String user, String password) {
InitialContext p =null;
Hashtable h = new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, url);
//h.put(Context.SECURITY_PRINCIPAL, user);
// h.put(Context.SECURITY_CREDENTIALS, password);
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My suggestion is to drop the transaction attribute from the QueueSession and make sure you properly close your resources. Would look something like this:


If this went anywhere beyond the simple example I would extract out the code in the finally block into a utility class to avoid copy-and-paste code.
[ April 11, 2006: Message edited by: Chris Mathews ]
 
Ken Rubin
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chris,

Either not using the transaction class or closing the connections has
gotten this to work. Will find out which one,

I thank you because I was (figuratively) knocking my head against the wall!

Ken
 
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic