geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacek Laskowski" <ja...@laskowski.net.pl>
Subject Re: Configure and Deploy JMS Resources in Geronimo 2.0.2
Date Tue, 06 Nov 2007 09:37:03 GMT
On 11/6/07, ivanrc <iriano@indra.es> wrote:

> and my jndi.parameters are...
>
> java.naming.factory.initial=org.apache.openejb.client.RemoteInitialContextFactory
> java.naming.provider.url=tcp://localhost:61616
> topic.MyTopic=jms/CustomerServiceTopic
>
> but always obtain javax.naming.NamingException: Cannot lookup

Use the remote client sample as a reference:

package pl.jaceklaskowski.ticketservice;

import java.util.Properties;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;

public class TicketServiceClient {

    private final static int NUMBER_OF_MESSAGES = 1;

    public static void main(String[] args) throws Exception {

        Properties env = new Properties();
        env.put(Context.PROVIDER_URL, "tcp://localhost:61616");
        env.put("connectionFactoryNames", "TicketConnectionFactory");
        env.put("queue.TicketQueue", "TicketQueue");
        Context jndiContext = new InitialContext(env);

        QueueConnectionFactory factory = (QueueConnectionFactory)
jndiContext.lookup("TicketConnectionFactory");
        Queue queue = (Queue) jndiContext.lookup("TicketQueue");

        QueueConnection connection = factory.createQueueConnection();
        QueueSession session = connection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(queue);

        for (int i = 0; i < NUMBER_OF_MESSAGES; i++) {
            System.out.println("Wysylana wiadomosc nr #" + i);
            TextMessage txtMsg = session.createTextMessage();
            txtMsg.setText("Wiadomosc od Jacka o numerze #" + i);
            producer.send(txtMsg);
        }

        session.close();
        connection.close();
    }
}

Change the managed object names appropriately.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Mime
View raw message