class AmqpItemReader<T> implements ItemReader<T> {

	private final AmqpTemplate amqpTemplate;

	private Class<? extends T> itemType;

	/**
	 * Initialize the AmqpItemReader.
	 * @param amqpTemplate the template to be used. Must not be null.
	 */
	public AmqpItemReader(final AmqpTemplate amqpTemplate) {
		Assert.notNull(amqpTemplate, "AmqpTemplate must not be null");

		this.amqpTemplate = amqpTemplate;
	}

	@Nullable
	@Override
	@SuppressWarnings("unchecked")
	public T read() {<FILL_FUNCTION_BODY>}

	/**
	 * Establish the itemType for the reader.
	 * @param itemType class type that will be returned by the reader.
	 */
	public void setItemType(Class<? extends T> itemType) {
		Assert.notNull(itemType, "Item type cannot be null");
		this.itemType = itemType;
	}

}

		if (itemType != null && itemType.isAssignableFrom(Message.class)) {
			return (T) amqpTemplate.receive();
		}

		Object result = amqpTemplate.receiveAndConvert();

		if (itemType != null && result != null) {
			Assert.state(itemType.isAssignableFrom(result.getClass()),
					"Received message payload of wrong type: expected [" + itemType + "]");
		}

		return (T) result;
	
<no_super_class>