Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 59123 invoked from network); 21 Sep 2009 07:23:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Sep 2009 07:23:03 -0000 Received: (qmail 39010 invoked by uid 500); 21 Sep 2009 07:23:02 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 38958 invoked by uid 500); 21 Sep 2009 07:23:02 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 38948 invoked by uid 99); 21 Sep 2009 07:23:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Sep 2009 07:23:02 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rafal.rusin@gmail.com designates 209.85.219.220 as permitted sender) Received: from [209.85.219.220] (HELO mail-ew0-f220.google.com) (209.85.219.220) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Sep 2009 07:22:51 +0000 Received: by ewy20 with SMTP id 20so2873682ewy.45 for ; Mon, 21 Sep 2009 00:22:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=eZ40C83HXTzG9LdibQQFWhVkOE+RDEpAhMqKZxr/J/U=; b=Y9xB5mGbHlzWNN8dODZZGS6lTSMZSCtRL88EUEkJ8ScuhVk9/RjshAgn3C9cP9UxQ0 jxVjslz62qRT0xuy4oeLeg/KfCFVqRUa8R3oOXVfSdm0WIxL2lxtoM6bzEiP9I+2Wmt7 afOn/BY9fxNseEgj61MMaPh7gbf/11iwQFRmw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=JtHYhLNVxmLLLDR4H0Li+fMoSn7Omgrl2N6Hb8vB1olHaIzmHHDmSPFSm/b6DKpAtr b4yk+boxnY8Hl9xcbhaMD1D++2zplZ18MsLOpjMu6P6gnCmRBZBl4PVnXlrnYOXwvUtR 3fVqxBuldGs7e8WsT1Mon9ITXOjkZWbxmAxNk= MIME-Version: 1.0 Received: by 10.216.10.3 with SMTP id 3mr1253584weu.60.1253517748346; Mon, 21 Sep 2009 00:22:28 -0700 (PDT) In-Reply-To: <4AB6D26F.90204@gmail.com> References: <4AB6D26F.90204@gmail.com> Date: Mon, 21 Sep 2009 09:22:28 +0200 Message-ID: <9bbf67fa0909210022h417e80fdp5fb6e5e4ece79c69@mail.gmail.com> Subject: Re: Spring JMS : can't receive message ? From: Rafal Rusin To: users@activemq.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Do you have broker running at tcp://localhost:61616? I don't see an entry for it in your spring config. If not, consider adding something like this: Regards, 2009/9/21 czy11421 : > Hi, All, > > I have tried to write a JMS with Spring, but failed. no compiler error, n= o > runtime error, just wait infinitely, can't receive message, but I am sure > the ActiveMQ is publishing data in 'STOCKS.SUNW' topic. > > Anybody has some clues ? Thanks. > > ///////////////////////// MessageReceiver.java ///////////////////////// > import javax.jms.JMSException; > import javax.jms.Message; > import javax.jms.TextMessage; > > import org.springframework.jms.core.JmsTemplate; > > public class MessageReceiver { > =C2=A0 private JmsTemplate jmsTemplate; > =C2=A0 public MessageReceiver() { > =C2=A0 } > > =C2=A0 public void setJmsTemplate(JmsTemplate jmsTemplate) { > =C2=A0 =C2=A0 =C2=A0 this.jmsTemplate =3D jmsTemplate; > =C2=A0 } =C2=A0 =C2=A0 =C2=A0 public void receiveMessage() { > System.out.println("receiving"); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Message message =3D jmsTemplate= .receive(); // wait infinitely > =C2=A0 =C2=A0 =C2=A0 System.out.println("Message=3D"+message); // never r= each here > =C2=A0 =C2=A0 =C2=A0 TextMessage textMessage =3D null; > =C2=A0 =C2=A0 =C2=A0 if (message instanceof TextMessage) { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 textMessage =3D (TextMessage) message; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 //.... > =C2=A0 =C2=A0 =C2=A0 } > =C2=A0 } > } > > ///////////////////////////////// > > //////////////////////// spring beans xml ///////////////////// > > > "http://www.springframework.org/dtd/spring-beans.dtd"> > > > =C2=A0 class=3D"org.apache.activemq.ActiveMQConnectionFactory"> > =C2=A0 =C2=A0 =C2=A0 > =C2=A0 > > =C2=A0 class=3D"org.springframework.jms.core.JmsTemplate"> > =C2=A0 =C2=A0 =C2=A0 > =C2=A0 =C2=A0 =C2=A0 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0 =C2=A0 =C2=A0 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0 =C2=A0 3000000 > =C2=A0 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 > > =C2=A0 > =C2=A0 =C2=A0 =C2=A0 > =C2=A0 > =C2=A0 =C2=A0 class=3D"org.apache.activemq.command.ActiveMQQueue"> > =C2=A0 =C2=A0 =C2=A0 > =C2=A0 > > > /////////////////////////// main class ///////////////////////// > > import org.springframework.context.ApplicationContext; > import org.springframework.context.support.ClassPathXmlApplicationContext= ; > > public class Test { > > =C2=A0 public static void main(String[] args) throws Exception { > =C2=A0 =C2=A0 =C2=A0 ApplicationContext ctx =3D new > ClassPathXmlApplicationContext("appContext.xml"); > > =C2=A0 =C2=A0 =C2=A0 MessageReceiver receiver =3D (MessageReceiver) > ctx.getBean("messageReceiver"); > > =C2=A0 =C2=A0 =C2=A0 receiver.receiveMessage(); > > =C2=A0 } > > } > --=20 Rafa=C5=82 Rusin http://www.touk.pl http://top.touk.pl http://www.mimuw.edu.pl/~rrusin