HI,

you need to define the : ConnectionFactory and TOPIC

b.l

2011/2/3 Rafał Laczek <rafal_lac...@wp.pl>

> Hi,
> Can somebody help me to get Message using following code.
>
> Thanks
> Rafal
>
>  try{
> Properties props = new Properties();
>  props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
>  "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
>  props.setProperty(Context.PROVIDER_URL,"tcp://srv-waw-323:61222");
> Context ctx = new InitialContext(props);
> // lookup the connection factory
> TopicConnectionFactory factory =
> (TopicConnectionFactory)ctx.lookup("ConnectionFactory");
>  // create a new TopicConnection for pub/sub messaging
>  TopicConnection conn = factory.createTopicConnection();
>  // create a new TopicSession for the client
>  TopicSession session =
> conn.createTopicSession(false,TopicSession.AUTO_ACKNOWLEDGE);
> // lookup an existing topic
> Topic mytopic = (Topic)ctx.lookup(TOPIC);
> // create a new subscriber to receive messages
> javax.jms.TopicSubscriber subscriber = session.createSubscriber(mytopic);
>  System.out.println("TopicSubscriber is "+ subscriber.getTopic());
>  } catch (Exception e) {
>       e.printStackTrace();
>
>                }
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Java EE (J2EE) Programming with Passion!" group.
> To post to this group, send email to
> java-ee-j2ee-programming-with-passion@googlegroups.com
> To unsubscribe from this group, send email to
> java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
> For more options, visit this group at
>
> http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en

Reply via email to