Contact Free trial Login

Avoid Changing the AMQP Topography - Mule 4

You can set the createFallbackExchange and createFallbackQueue global config properties so that the declaration of AMQP exchanges and queues is disabled. These parameters have been added for those scenarios where it must be guaranteed that no changes to the AMQP topography will be attempted. In those cases, both the declaration of queues and exchanges which do not previously exist will result in an AMQP:CREATION_NOT_ALLOWED error.

For example, in the following flow:

<amqp:config name="Amqp_Config" createFallbackExchange="false" >
	<amqp:connection host="localhost" username="guest" password="guest" />
</amqp:config>


<flow name="mule-no-create-fallback-queue">
	<http:listener
		doc:name="Listener"
		config-ref="HTTP_Listener_config"
		path="/"/>
	<amqp:publish
		doc:name="Publish"
		config-ref="Amqp_Config"
		exchangeName="newExchange">
		<amqp:fallback-exchange-definition />
	</amqp:publish>
</flow>

If the newExchange exchange does not exist and the createFallbackExchange is set to false, an invocation of the publish operation causes an AMQP:CREATION_NOT_ALLOWED error. Notice that the createFallbackExchange can be overridden at the operation level and it can get an expression as a value. For example:

<flow name="mule-no-create-fallback-queue">
	<http:listener doc:name="Listener"config-ref="HTTP_Listener_config" path="/"/>
	<amqp:publish
		doc:name="Publish"
		config-ref="Amqp_Config"
		exchangeName="newExchange"
		createFallbackExchange="false">
		<amqp:fallback-exchange-definition />
	</amqp:publish>
</flow>

The use of createFallbackQueue parameter in a consume operation is analogous:

<amqp:config
	name="Amqp_Config"
	createFallbackQueue="false" >
	<amqp:connection
		host="localhost"
		username="guest"
		password="guest" />
</amqp:config>


<flow name="mule-no-create-fallback-queue">
	<http:listener
		doc:name="Listener"
		config-ref="HTTP_Listener_config"
		path="/"/>
	<amqp:consume
		config-ref="Amqp_Config"
		queueName="testQueue">
		<amqp:fallback-queue-definition
			removalStrategy="SHUTDOWN"
			exchangeToBind="exchangeToBindToQueue" />
	</amqp:consume>
</flow>

You can also use this parameter in the listener:

<amqp:config
	name="Amqp_Config"
	createFallbackQueue="false" >
	<amqp:connection
		host="localhost"
		username="guest"
		password="guest" />
</amqp:config>


<flow name="mule-no-create-fallback-queue">
	<amqp:listener
		config-ref="Amqp_Config"
		queueName="testQueue">
		<amqp:fallback-queue-definition
			removalStrategy="SHUTDOWN"
			exchangeToBind="exchangeToBindToQueue" />
	</amqp:listener>
	<amqp:consume
		config-ref="Amqp_Config"
		queueName="testQueue">
		<amqp:fallback-queue-definition
			removalStrategy="SHUTDOWN"
			exchangeToBind="exchangeToBindToQueue" />
	</amqp:consume>
</flow>