Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receiver fail to get Channel #972

Closed
kc910521 opened this issue Apr 9, 2019 · 1 comment
Closed

Receiver fail to get Channel #972

kc910521 opened this issue Apr 9, 2019 · 1 comment

Comments

@kc910521
Copy link
Contributor

kc910521 commented Apr 9, 2019

**Affects Version(s):1.7.6 <>


my receiver like:

public void processCDN(Object obj1, Object message, Object channel) throws IOException {
        logger.info("consumerContent:" + message);
//        this.msgNullRefusal(content, channel, message);
//        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }

my config like:

    @Bean("simpleMessageListenerContainer")
    public SimpleMessageListenerContainer simpleMessageListenerContainer(ConnectionFactory cachingConnectionFactory, DirectConsumerListener directConsumerListener) {
        SimpleMessageListenerContainer simpleMessageListenerContainer = new SimpleMessageListenerContainer();
        simpleMessageListenerContainer.setQueueNames(MQInfoEnum.PACK_CDN.getQueueName() + (MQInfoEnum.PACK_CDN.isSuffixIpHostOnStart() ? NetUtil.getHostIp() : ""));
        simpleMessageListenerContainer.setDefaultRequeueRejected(false);
        simpleMessageListenerContainer.setAcknowledgeMode(AcknowledgeMode.MANUAL);
        simpleMessageListenerContainer.setExposeListenerChannel(true);
        simpleMessageListenerContainer.setChannelTransacted(true);
        simpleMessageListenerContainer.setConnectionFactory(cachingConnectionFactory);
        MessageListenerAdapter messageListenerAdapter = new MessageListenerAdapter(directConsumerListener);
        HashMap<String, String> queueOrTagToMethodName = Maps.newHashMap();
        queueOrTagToMethodName.put(MQInfoEnum.PACK_CDN.getQueueName() + (MQInfoEnum.PACK_CDN.isSuffixIpHostOnStart() ? NetUtil.getHostIp() : ""), "processCDN");
        messageListenerAdapter.setQueueOrTagToMethodName(queueOrTagToMethodName);
        simpleMessageListenerContainer.setMessageListener(messageListenerAdapter);
        return simpleMessageListenerContainer;
    }

There are the only message could be received because of MessageListenerAdapter,
so I cannot have channel.basicAck

@garyrussell
Copy link
Contributor

GitHub Issues are not for asking questions, they are for reporting bugs or asking for new features. Ask questions on Stack Overflow, tagged with [spring-amqp].

You can't get the Channel with that old style listener adapter; use the newer Annotation-based listener adapter instead. See the documentation.

See this stack overflow answer for an example.

If you have further question, please ask on Stack Overflow, and be very specific.

artembilan pushed a commit that referenced this issue Apr 29, 2019
Fixes #972

format code

sorry for skipping formation

format

blank format

fix method name

polymorphisms of method buildListenerArguments

deprecated buildListenerArguments and doc append

fix grammar

fix doc

fix SuppressWarnings position

fix Deprecated annotation

test case code improved

fix blank

fix link in comment

fix doc

fix name

improve doc

improve doc

*Polishing JavaDocs and Docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants