Deal of the Day

Home » Main » Manning Forums » 2008 » ActiveMQ in Action

Thread: Chapter 3 - Running the Stock Portfolio Example

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 7 - Pages: 1 - Last Post: Nov 8, 2013 1:45 PM by: bsnyder
Anantha

Posts: 4
Registered: 6/2/10
Chapter 3 - Running the Stock Portfolio Example
Posted: Jun 4, 2010 11:20 AM
  Click to reply to this thread Reply

Hi i am unable to execute the stock portfolio example..first as instructed i started the ActiveMQ by using the command ./bin/activemq it works fine...after that i opened a new terminal to start the consumer and i went to the folder of the example in command line which is desktop/amq-in-action-example-src...then i executed this command mvn exec:java \-Dexec.mainClass=org.apache.activemq.book.ch3.portfolio.Consumer

i am getting the following output

urmobile1s-iMac:amq-in-action-example-src urmobile1$ mvn exec:java \-Dexec.mainClass=org.apache.activemq.book.ch3.portfolio.Consumer
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'exec'.
[INFO] ------------------------------------------------------------------------
[INFO] Building ActiveMQ in Action Examples
[INFO] task-segment: [exec:java]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing exec:java
[INFO] No goals needed for project - skipping
Downloading: http://download.java.net/maven/2/net/sf/josql/josql/1.5/josql-1.5.pom
Downloading: http://repo1.maven.org/maven2/net/sf/josql/josql/1.5/josql-1.5.pom
Downloading: http://download.java.net/maven/2/net/sf/josql/gentlyweb-utils/1.5/gentlyweb-utils-1.5.pom
Downloading: http://repo1.maven.org/maven2/net/sf/josql/gentlyweb-utils/1.5/gentlyweb-utils-1.5.pom
Downloading: http://download.java.net/maven/2/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom
Downloading: http://repo1.maven.org/maven2/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom
[INFO] [exec:java]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An exception occured while executing the Java class. org.apache.activemq.book.ch3.portfolio.Consumer

[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Fri Jun 04 11:45:15 CDT 2010
[INFO] Final Memory: 23M/79M
[INFO] ------------------------------------------------------------------------
urmobile1s-iMac:amq-in-action-example-src urmobile1$


I am getting BULID ERROR

Can anyone please help me out in this..i have installed maven too..i did the procedure as per the book...can any one plzz suggest some ways to make it work plzz.

bsnyder

Posts: 156
From: Boulder, CO
Registered: 9/19/06
Re: Chapter 3 - Running the Stock Portfolio Example
Posted: Jun 4, 2010 1:49 PM   in response to: Anantha in response to: Anantha
  Click to reply to this thread Reply

First you must build the source code as described in chapter 3:

'...
After expanding the zip file containing the example source code, you will be ready to compile the examples. To do so, move into the amq-in-action-example-src directory and run the following command:

[amq-in-action-example-src] $ mvn clean install
...'

I hope that helps.

Bruce

Anantha

Posts: 4
Registered: 6/2/10
Re: Chapter 3 - Running the Stock Portfolio Example
Posted: Jun 4, 2010 2:49 PM   in response to: bsnyder in response to: bsnyder
  Click to reply to this thread Reply

Hi Bruce thx for your reply..as u said i did mvn clean install..

this time in the consumer it shows up like this


urmobile1s-iMac:amq-in-action-example-src urmobile1$ mvn exec:java \-Dexec.mainClass=org.apache.activemq.book.ch3.portfolio.Consumer
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'exec'.
[INFO] ------------------------------------------------------------------------
[INFO] Building ActiveMQ in Action Examples
[INFO] task-segment: [exec:java]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing exec:java
[INFO] No goals needed for project - skipping
Downloading: http://download.java.net/maven/2/net/sf/josql/josql/1.5/josql-1.5.pom
Downloading: http://repo1.maven.org/maven2/net/sf/josql/josql/1.5/josql-1.5.pom
Downloading: http://download.java.net/maven/2/net/sf/josql/gentlyweb-utils/1.5/gentlyweb-utils-1.5.pom
Downloading: http://repo1.maven.org/maven2/net/sf/josql/gentlyweb-utils/1.5/gentlyweb-utils-1.5.pom
Downloading: http://download.java.net/maven/2/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom
Downloading: http://repo1.maven.org/maven2/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom
[INFO] [exec:java]
log4j:WARN Continuable parsing error 47 and column 23
log4j:WARN An element with the identifier "FILE" must appear in the document.
log4j:WARN No such property [file] in org.apache.log4j.PatternLayout.
log4j:ERROR No appender named [FILE] could be found.



it is showing some log4j warning and it stop as it is...i tried to run producer this time it works by sending all the 1000 meassages..but i have problem with consumer..why it stops as it is...can u plz suggest some ideas plzzz..

bsnyder

Posts: 156
From: Boulder, CO
Registered: 9/19/06
Re: Chapter 3 - Running the Stock Portfolio Example
Posted: Jun 4, 2010 2:59 PM   in response to: Anantha in response to: Anantha
  Click to reply to this thread Reply

Indeed, it appears that there is an error with the log4j.xml file. The FILE appender is not defined which is causing the error. To quickly solve this problem, please replace the contents of your log4j.xml file with the following:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

<!-- Filter debug log messages to the console -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} | %5p | %m%n" />
<param name="File" value="target/test.log" />
</layout>
</appender>

<appender name="FILE" class="org.apache.log4j.FileAppender">
<param name="threshold" value="DEBUG"/>
<param name="File" value="target/test.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} | %-5p | %-10t | %-24.24c{1} | %-30.30C %4L | %m%n"/>
</layout>
</appender>


<logger name="org.springframework">
<level value="info" />
</logger>

<logger name="org.apache.activemq">
<level value="info" />
</logger>

<logger name="org.apache.activemq.book">
<level value="debug" />
</logger>

<root>
<priority value="debug" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>

</log4j:configuration>


This should get you past the errors.

Bruce

Anantha

Posts: 4
Registered: 6/2/10
Re: Chapter 3 - Running the Stock Portfolio Example
Posted: Jun 5, 2010 10:30 AM   in response to: bsnyder in response to: bsnyder
  Click to reply to this thread Reply

Hi Bruce i changed the content in the log4j.xml folder which is present at the resources folder..but the consumer still outputs like this...


urmobile1s-iMac:amq-in-action-example-src urmobile1$ mvn exec:java \-Dexec.mainClass=org.apache.activemq.book.ch3.portfolio.Consumer
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'exec'.
[INFO] ------------------------------------------------------------------------
[INFO] Building ActiveMQ in Action Examples
[INFO] task-segment: [exec:java]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing exec:java
[INFO] No goals needed for project - skipping
Downloading: http://download.java.net/maven/2/net/sf/josql/josql/1.5/josql-1.5.pom
Downloading: http://repo1.maven.org/maven2/net/sf/josql/josql/1.5/josql-1.5.pom
Downloading: http://download.java.net/maven/2/net/sf/josql/gentlyweb-utils/1.5/gentlyweb-utils-1.5.pom
Downloading: http://repo1.maven.org/maven2/net/sf/josql/gentlyweb-utils/1.5/gentlyweb-utils-1.5.pom
Downloading: http://download.java.net/maven/2/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom
Downloading: http://repo1.maven.org/maven2/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom
[INFO] [exec:java]
log4j:WARN No such property [file] in org.apache.log4j.PatternLayout.

the output stops here..can you please suggest me in this...

Job Queues example works fine for me..i am not sure why this doesn't work...

bsnyder

Posts: 156
From: Boulder, CO
Registered: 9/19/06
Re: Chapter 3 - Running the Stock Portfolio Example
Posted: Jun 15, 2010 1:21 AM   in response to: Anantha in response to: Anantha
  Click to reply to this thread Reply

Whoops, it looks like the file property listed beneath the CONSOLE's PatternLayout should not be there. Try the following contents for the src/main/log4j.xml file:


<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

<!-- Filter debug log messages to the console -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} | %5p | %m%n" />
</layout>
</appender>

<appender name="FILE" class="org.apache.log4j.FileAppender">
<param name="threshold" value="DEBUG"/>
<param name="File" value="target/test.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} | %-5p | %-10t | %-24.24c{1} | %-30.30C %4L | %m%n"/>
</layout>
</appender>


<logger name="org.springframework">
<level value="info" />
</logger>

<logger name="org.apache.activemq">
<level value="info" />
</logger>

<logger name="org.apache.activemq.book">
<level value="debug" />
</logger>

<root>
<priority value="debug" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>

</log4j:configuration>


I just tested this myself so I know it works correctly.

Bruce

liam21c

Posts: 1
From: Vienna
Registered: 10/14/13
Re: Chapter 3 - Running the Stock Portfolio Example
Posted: Oct 14, 2013 6:23 AM   in response to: Anantha in response to: Anantha
  Click to reply to this thread Reply

Hello!

where can I get the source code for this example?
the link in the book leads to a 404 message..

Does anybody know where/how to get the source codes?

thx..

bsnyder

Posts: 156
From: Boulder, CO
Registered: 9/19/06
Re: Chapter 3 - Running the Stock Portfolio Example
Posted: Nov 8, 2013 1:45 PM   in response to: liam21c in response to: liam21c
  Click to reply to this thread Reply

It is available in the source download or in the source repository.

Here is the URL to the source download:

http://manning.com/snyder/AMQinA-src.zip

You will find the log4j.xml file in src/main/resources/log4j.xml.

Bruce

Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Manning Developmental Editor