Skip to content

onMessageReceived sometimes unable to update class property #12

@nurettin

Description

@nurettin

I connect the consumer's "MessageReceived" event to a class method

           addlistener(obj.consumer,'MessageReceived',@obj.on_rabbitmq_message_received)

Then I use the class method to update a class property whenever a message is received.

        function on_rabbitmq_message_received(obj, ~, message)
            json = jsondecode(message.message);
            if isfield(json, 'positions')                
                obj.positionsTable = struct2table(json.positions);
                % disp(obj.positionsTable);
            end
        end

I have a loop which calls disp(obj.positionsTable). If I receive a message while trying to display the table, the table isn't updated. I have to send message twice to get it updated.

Am I misunderstanding how the listener works? Or is there a way to lock the table in order to replace its value?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions