25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 20 ■ Your First <strong>Spring</strong> XD Application<br />

Now let’s start the <strong>Spring</strong> XD shell. This tool will be used to create the stream and tap that you are going to use to<br />

count how many PDFs the My Documents <strong>Spring</strong> application receives. The <strong>Spring</strong> XD shell uses a high-level DSL to<br />

define all the tasks needed.<br />

You can open a new terminal and run the following command to start the <strong>Spring</strong> XD shell tool, as shown in<br />

Figure 20-4:<br />

xd-shell<br />

Figure 20-4. <strong>Spring</strong> XD Shell<br />

Figure 20-4 shows the <strong>Spring</strong> XD shell, a tool that will interact with the <strong>Spring</strong> XD itself. Next, you are going<br />

to create the stream that will be listening from the RabbitMQ on one of your queues, in this case the docs-pdf. The<br />

following command will create the stream you need:<br />

xd:> stream create –-name docs-pdf –-definition "rabbit | log"<br />

The above command will create a rabbit stream and it will log all the incoming messages into the console. It is<br />

important to note that the name parameter is key and is related to the name of a queue. So the name “docs-pdf” is the<br />

name of the queue in RabbitMQ; if this name does not exist in RabbitMQ, it will be created.<br />

Next, let’s create the tap that will end in a sink (counter) that will have the number of the PDFs. The following<br />

command in the <strong>Spring</strong> shell will create the tap (see Figure 20-5):<br />

xd:> stream create --name pdftap --definition "tap:stream:docs-pdf > counter --name=pdfcount"<br />

280

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!