Skip to content

Creating subscriber application Part 1

rmuthupandian edited this page Feb 11, 2015 · 1 revision

In this part we will help you on Subscriber. Please start running Subscriber firstly so that when the Publisher starts publishing, data won't be ended up in garbage.

Cutting it short, let's start with the Subscriber configurations.

Look for folder "buildsrc" in your project. Inside this you will see "JetstreamConf" folder. Expand folder to see XML files appwiring.xml and messagecontext.xml. You can name these files as you like. Eg. appwiring.xml can be named subscriberwiring.xml. We choose these since subscriberwiring talks about the pipeline wiring involving the Subscriber and messagecontext defines beans for Message delivery etc. JetStream will merge these xmls during runtime.

Follow these steps for subcriberwiring.xml:

  • You will see below Spring XML configuration fragment.
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"
    default-lazy-init="false">

</beans>

This is a boilerplate that allows you to take advantage of the new Spring 4.0 XML tags since they make configuration easier.

  • See these beans inside the fragment in #1:
	<bean id="InboundMessageBinder" scope="singleton"
		class="com.ebay.jetstream.event.support.channel.ChannelBinding"
		depends-on="MessageService">
		<property name="channel" ref="InboundMessages">
		</property>
	</bean>

	<bean id="InboundMessages"
		class="com.ebay.jetstream.event.channel.messaging.InboundMessagingChannel">
		<property name="address" ref="InboundChannelAddress" />
	</bean>

	<bean id="InboundChannelAddress"
		class="com.ebay.jetstream.event.channel.messaging.MessagingChannelAddress">
		<property name="channelTopics">
			<list>
				<value>Jetstream.demo/Person</value>

			</list>
		</property>
	</bean>

An “InboundMessageChannel” bean can subscribe to zero or more topics. This bean has a property named “address” which has a reference to another bean named “InboundChannelAddress”. The “InboundChannelAddress” bean holds a list of [message topics] (../wiki/Message-service-Topic) subscribed to by the “InboundMessages” bean.

[Next: Creating subscriber application Part 2] (../wiki/Creating-subscriber-application-Part-2)

Clone this wiki locally