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

Messages order breaks with versions 3.2+ #2513

Closed
ochtarfear opened this issue May 21, 2014 · 2 comments
Closed

Messages order breaks with versions 3.2+ #2513

ochtarfear opened this issue May 21, 2014 · 2 comments
Assignees
Milestone

Comments

@ochtarfear
Copy link

Starting with version 3.2 the order of message delivery breaks.

Here's the test code:

public class TopicsTest {

    private static final String TOPIC = "test";
    private static final String REQUESTS_PROCESSOR = "requestsProcessor";

    private static final int MESSAGES_NUMBER = 30;

    public static void main(String[] args) {

        Hazelcast.newHazelcastInstance();
        HazelcastInstance client = HazelcastClient.newHazelcastClient();

        ITopic<Integer> topic = client.getTopic(TOPIC);
        topic.addMessageListener(new IntegerMessageListener());

        IExecutorService executorService = client.getExecutorService(REQUESTS_PROCESSOR);
        executorService.submit(new SendingCallable());
    }

    static class IntegerMessageListener implements MessageListener<Integer> {

        boolean broken = false;
        int expected = 1;
        List<Integer> received = new ArrayList<>();

        @Override
        public synchronized void onMessage(Message<Integer> message) {
            Integer messageObject = message.getMessageObject();
            received.add(messageObject);
            if (!broken && expected != messageObject){
                System.out.println("Order breaks at " + expected);
                broken = true;
            }
            expected++;
            if (received.size() == MESSAGES_NUMBER){
                System.out.println("Result: " + received);
            }

        }
    }

    static class SendingCallable implements Callable<Void>, HazelcastInstanceAware, Serializable {

        private HazelcastInstance hazelcastInstance;

        @Override
        public Void call() throws Exception {
            ITopic<Object> topic = hazelcastInstance.getTopic(TOPIC);
            for (int i = 1; i <= MESSAGES_NUMBER; i++) {
                topic.publish(i);
            }
            return null;
        }

        @Override
        public void setHazelcastInstance(HazelcastInstance hazelcastInstance) {
            this.hazelcastInstance = hazelcastInstance;
        }
    }
}

Everything's fine with the version 3.1.7, but since 3.2 it doesn't work.

Same with order of notification of map's EntryListener and collection's ItemListener

@pveentjer
Copy link
Contributor

Thanks for this bug report and the test to reproduce it. Reproducing an issue often is a big time consumer.

@pveentjer pveentjer added this to the 3.2.2 milestone May 21, 2014
@enesakar enesakar modified the milestones: 3.2.3, 3.2.2 May 22, 2014
@sancar
Copy link
Contributor

sancar commented Jun 3, 2014

related to #2607
Order is broken with same reason. You can follow other issue, closing this one. Thanks for test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants