<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
	xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0"
	xsi:schemaLocation="
		http://www.osgi.org/xmlns/blueprint/v1.0.0 
		http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd

		http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
		http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd

		http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0
		http://aries.apache.org/schemas/blueprint-ext/blueprint-ext-1.1.xsd
">

	<bean id="queueNameFactory" class="org.opennms.core.camel.JmsQueueNameFactory">
		<argument value="Trapd"/>
		<argument value="BroadcastTrap"/>
	</bean>

	<cm:property-placeholder id="trapHandlerMinionProperties" persistent-id="org.opennms.netmgt.trapd.handler.minion" update-strategy="none">
		<cm:default-properties>
			<cm:property name="queueName">
				<bean factory-ref="queueNameFactory" factory-method="getName"/>
			</cm:property>
		</cm:default-properties>
	</cm:property-placeholder>

	<bean id="trapdNotificationHandlerCamel" class="org.opennms.netmgt.trapd.TrapNotificationHandlerCamelImpl">
		<argument value="seda:handleMessage" />
	</bean>

	<service interface="org.opennms.netmgt.trapd.TrapNotificationHandler" ref="trapdNotificationHandlerCamel" />

	<!-- ActiveMQ component provided by minion-core -->
	<reference id="queuingservice" interface="org.apache.camel.Component" filter="(alias=opennms.broker)"/>

	<!-- @see http://www.davsclaus.com/2012/06/locking-down-jmx-naming-now-easier-with.html -->
	<camelContext id="trapdHandlerMinionContext" managementNamePattern="#name#" xmlns="http://camel.apache.org/schema/blueprint">
		<propertyPlaceholder id="properties" location="blueprint:trapHandlerMinionProperties" />

		<route id="trapMarshal">
			<from uri="seda:handleMessage?concurrentConsumers=4"/>
			<!-- Marshal the message to XML -->
			<!-- TODO: HZN-766: Implement this marshaller -->
			<!-- <bean ref="marshaller"/> -->
			<to uri="seda:sendMessage"/>
		</route>

		<route id="trapSendJms">
			<from uri="seda:sendMessage?concurrentConsumers=4"/>

			<!-- Broadcast message over ActiveMQ -->
			<to uri="queuingservice:{{queueName}}?disableReplyTo=true" />
		</route>
	</camelContext>

</blueprint>
