activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Posta <christian.po...@gmail.com>
Subject Re: help on topic and queue communication please
Date Fri, 15 Feb 2013 05:31:42 GMT
Maybe give Virtual Topics a shot if your'e looking for put-sub and also
durable semantics without durable subscribers:
http://activemq.apache.org/virtual-destinations.html


On Thu, Feb 14, 2013 at 8:15 PM, SuoNayi <suonayi2006@163.com> wrote:

> You publish messages on the topic and expect receiving messages from the
> queue, even if they are the same name but they are different thing in JMS
> specification.
>  Your consumers can subscribe the topic where your producers publish
> messages for receiving messages.
>
>
>
>
> At 2013-02-13 21:18:09,"Sule BASOL" <kadirbasol@icloud.com> wrote:
> >       Hi , i'm using openejb with activemq but they run on separate jvms.
> >
> >i tried ;
> >
> >on openejb jvm :
> >
> >@Singleton
> >@ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
> >public class MonitoringTimerService {
> >    @PostConstruct
> >    private void init() {
> >            final Hashtable<String, String> ctxProps = new
> Hashtable<String, String>(2);
> >            ctxProps.put("java.naming.factory.initial",
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
> >            ctxProps.put("java.naming.provider.url",
> "tcp://localhost:61616");
> >
> >            final InitialContext activeMQInitialContext = new
> InitialContext(ctxProps);
> >
> >            final javax.jms.ConnectionFactory factory =
> (javax.jms.ConnectionFactory)activeMQInitialContext.lookup("ConnectionFactory");
> >            final Connection connection = factory.createConnection();
> >            session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> >
> >            connection.start();
> >
> >            topic = session.createTopic( "screenNotifications" );
> >            producer = session.createProducer(topic);
> >       }
> >
> >    @Lock(LockType.WRITE)
> >    @Schedule(second="*/15", minute="*",hour="*",dayOfMonth = "*",
> persistent=false)
> >    public void deleteLogs(){
> >        //check if...
> >        System.out.println("checking");
> >
> >
> >        try {
> >            TextMessage message = session.createTextMessage("Test 1 2 3");
> >            producer.send(message);
> >        } catch (JMSException e) {
> >            e.printStackTrace();  //To change body of catch statement use
> File | Settings | File Templates.
> >        }
> >
> >
> >        System.out.println("done");
> >
> >    }
> >}
> >
> >
> >
> >This code opens screenNotifications jms topic and sends message every 15
> seconds like that :
> >
> >
> >
> >
> >
> >Then i've second java swing client that listens for messages from
> "screenNotifications" like shown below :
> >
> >
> >InitialContext activeMQInitialContext = getActiveMQInitialContext();
> >
> >                javax.jms.ConnectionFactory factory =
> (javax.jms.ConnectionFactory)activeMQInitialContext.lookup("ConnectionFactory");
> >                final Connection connection = factory.createConnection();
> >
> >                final Session session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> >
> >                Destination destination =
> session.createQueue("screenNotifications");
> >
> >                // MessageConsumer is used for receiving (consuming)
> messages
> >                MessageConsumer consumer =
> session.createConsumer(destination);
> >
> >                consumer.setMessageListener( this );
> >
> >
> >
> >    @Override
> >    public void onMessage(Message message) {
> >        //To change body of implemented methods use File | Settings |
> File Templates.
> >        System.out.println("Deneme");
> >    }
> >
> >
> >
> >
> >
> >But i dont get any message from openejb server although queue name with
> topic is same , whats wrong ?
> >
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message