Problem with  SimpleQueueSender

10-11  Source: Network gathering  Views:0 

Have tried SimpleQueueSender seems that message is null.
Queue is set to MyQueue so its not null but
message =queueSession.createTextMessage();
always yields a null value .
Please help
=================== Code -======================
import javax.jms.*;
import javax.naming.*;
public class SimpleQueueSender {
* Main method.
* @param args the queue used by the example and,
* optionally, the number of messages to send
public static void main(String[] args) {
String queueName = null;
Context jndiContext = null;
QueueConnectionFactory queueConnectionFactory = null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueSender queueSender = null;
TextMessage message = null;
final int NUM_MSGS;
if ( (args.length < 1) || (args.length > 2) ) {
System.out.println("Usage: java SimpleQueueSender " +
"<queue-name> [<number-of-messages>]");
queueName = new String(args[0]);
System.out.println("Queue name is " + queueName);
if (args.length == 2){
NUM_MSGS = (new Integer(args[1])).intValue();
} else {
* Create a JNDI API InitialContext object if none exists
* yet.
try {
jndiContext = new InitialContext();
} catch (NamingException e) {
System.out.println("Could not create JNDI API " +
"context: " + e.toString());
* Look up connection factory and queue. If either does
* not exist, exit.
try {
queueConnectionFactory = (QueueConnectionFactory)
queue = (Queue) jndiContext.lookup(queueName);
} catch (NamingException e) {
System.out.println("JNDI API lookup failed: " +
* Create connection.
* Create session from connection; false means session is
* not transacted.
* Create sender and text message.
* Send messages, varying text slightly.
* Send end-of-messages message.
* Finally, close connection.
System.out.println("nakarating dito");
try {
queueConnection =
queueSession =
queueSender = queueSession.createSender(queue);
message = queueSession.createTextMessage();
System.out.println("queueSender:" + queueSender);
System.out.println("queueSession" + queueSession);
System.out.println("message:" + message);
System.out.println("queue:" + queue);
for (int i = 0; i < NUM_MSGS; i++) {
                    TextMessage mymessage = queueSession.createTextMessage();
                    System.out.println("mymessage:" + mymessage);
                    mymessage.setText("Test lang po"); // msg_text is a String
// message.setText("This is message " + (i + 1));
System.out.println("Sending message: " );
// + message.getText());
// queueSender.send(message);
* Send a non-text control message indicating end of
* messages.
} catch (JMSException e) {
System.out.println("Exception occurred: " +
} finally {
if (queueConnection != null) {
try {
} catch (JMSException e) {}
I am using j2ee 1.3.xx jms provider. In which by default has that MyQueueStarting JMS service...
So all of the administered objects are fine except that queueSession.CreateMessage() always yields a null object.
I have paste my j2ee console message on startup.
Initialization complete - waiting for client requests
Binding: < JMS Destination : jms/Topic , javax.jms.Topic >
Binding: < JMS Destination : MyQueue , javax.jms.Queue >
Binding: < JMS Destination : jms/Queue , javax.jms.Queue >
Binding: < JMS Cnx Factory : jms/QueueConnectionFactory , Queue , No properties
Binding: < JMS Cnx Factory : jms/TopicConnectionFactory , Topic , No properties
Binding: < JMS Cnx Factory : TopicConnectionFactory , Topic , No properties >
Binding: < JMS Cnx Factory : QueueConnectionFactory , Queue , No properties >
Starting web service at port: 8000
Related articles
  • Problem with  SimpleQueueSender 10-11

    Have tried SimpleQueueSender seems that message is null. Queue is set to MyQueue so its not null but message =queueSession.createTextMessage(); always yields a null value . Please help =================== Code -====================== import javax.jms

  • A problem with threads 10-11

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be ab

  • Problem with Threads and a static variable 10-11

    I have a problem with the code below. I am yet to make sure that I understand the problem. Correct me if I am wrong please. Code functionality: A timer calls SetState every second. It sets the state and sets boolean variable "changed" to true. T

  • Problem with threads running javaw 10-11

    Hi, Having a problem with multi thread programming using client server sockets. The program works find when starting the the application in a console using java , but when using javaw the program doesnt die and have to kill it in

  • Problem with threads and camera. 10-11

    Hi everybody! I've a problem with taking snapshot. I would like to display a loading screen after it take snapshot ( sometimes i have to wait few seconds after i took snapshot. Propably photo is being taken in time where i have to wait). I was trying

  • Problem with threads hanging 10-11

    We have a problem where our application stops responding after a few days of usage. Things will for fine for a day or two, and then pretty quickly threads will start getting hung up, usually in places where they are allocating memory We are running W

  • Problem with threads and ProgressMonitor 10-11

    Dear Friends: I have a little problem with a thread and a ProgressMonitor. I have a long time process that runs in a thread (the thread is in an separate class). The thread has a ProgressMonitor that works fine and shows the tasks progress. But I nee

  • Problem with threads and/or memory 10-11

    I'm developing an application where there are 3 threads. One of them sends a request to the other, and if the 2nd can't answer it, it sends it to the 3rd (similar to CPU -> CACHE -> MEMORY). When i run the program with 1000-10.000 requests, no probl

  • Installation problem with NW'04 SR1: database connection failed 10-11

    Hi all, while installing NW '04 SR1 on Windows Server 2003 SP1 and MS SQL Server 2000 SP4 I ran into an error related to the database connection. While performing the step "Load Java Database content" SAPinst crashes with the message

  • My app store wont let me download apps, says the card is expired and theres a problem with previous purchase can someone help me pls? 10-11

    My app store wont let me download apps, asks me to update my payment details then says theres a problem with previous purchase and card is expired which is untrue someone help me plsThis is a User to User Forum... See Here for Mac Apps Store Customer

  • Problem with item and/or data during page-processing-PS/SQL 10-11

    Greetings! On my page I have a custom report (from 2 tables) and a small form-field, that adds and edits data in the report. After generating the form with the wizard I added an extra item, to store the id from one of the tables from the report data.

  • Problem with Gnome3 and/or graphics card Nvidia 8600M GT 10-11

    Feb 22 07:40:21 localhost dbus[712]: [system] Failed to activate service 'org.freedesktop.Avahi': timed out Feb 22 07:50:30 localhost kernel: [ 679.031379] gnome-shell[1277]: segfault at 10 ip 00007f3bbd305c0f sp 00007f3b84ff86d8 error 6 in libnvidia

  • I have a problem with wifi in my iphone 4s, i already try everything and download latest version 7.1(11D167) but wifi switch is not working, its my humble request to Apple support team that pls resolve this problem as soon as possible because 10-11

    I have a problem with wifi in my iphone 4s, i already try everything and download latest version 7.1(11D167) but wifi switch is not working, its my humble request to Apple support team that pls resolve this problem as soon as possible because its a p

  • Having a problem with eBooks in my iTunes library. 10-11

    As the title says, I'm having some problems with the iTunes library not reflecting what's actually on the disk. I add the ebook and it seems to add ok.  The file gets consolidated into /mymusic/books under the author correctly, but the book is missin

  • Got a problem with BIOS in my board MSI 785GM-E51 10-11

    i have a MSI 785GM-E51 board,i got a problem with the graphic card bus interface,it still run in 8x not in 16x i try to disable a onboard graphic on BIOS,but i not find it. and last i try to update BIOS to v2.4 n' not work too. this a example;Quote f

  • I have problem with buy in my visa 10-11

    hello i have problem with buy if i want buy show me this massge ( your purchase could not be completed ) for assistance, contact  itunes support at here and ask the iTunes Store staff for assistance. There are many reasons that mes

  • Problem with logging in to apex application builder listener 10-11

    I have problem with my settings and am posting this in hope that someone else out there had similar problem and solved it! I am trying to use reverseproxy to access to our db through apex listener. It's been all set-up and I can login to the applicat

  • Problem with plugins in my web site 10-11

    Problem with plugins in my web site PLS HELP i'm pretty sure you're going to get no help unless you supply some helpful information.Read other 2 answers

  • Problem with jDialog in a JFrame 10-11

    Hello to everyone...i'm newby java GUI developer, and i've got a problem with a JDialog within a JFrame... I made a JFrame which creates a new customized JDialog in his contructor, like this: MioJdialog dlg = new MioJdialog(this, true); dlg.setVisibl

  • Problem with setContentPane() in JFrame class 10-11

    I recently discovered a problem with the setContentPane method in the JFrame class. When I use setContentPane(Container ..), the previously existing contentPane remains in the stack. I have tried nullifying getContentPane(), and all manner of things,