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

QueuedMessageRouter does not work : message are not sent to queue #979

Open
bizulk opened this issue Nov 26, 2024 · 4 comments
Open

QueuedMessageRouter does not work : message are not sent to queue #979

bizulk opened this issue Nov 26, 2024 · 4 comments
Assignees
Labels

Comments

@bizulk
Copy link

bizulk commented Nov 26, 2024

Using last commit in master (a88a48d)
Running under ubuntu 22 linux desktop (amd64), this is the output result :

  Received message 1 : '1'
  Received message 1 : '2'
  Received message 2 : '1.2'
  Received message 2 : '3.4'
  Received message 3 : 'Hello'
  Received message 3 : 'World'
  Received unknown message 4

After running in debug mode I found out that we never jump into the overrided receive that use the generic message, but the templated one. The only way to force going to the overrided receive in the example is to static cas the message to the generic type (or declare a generic variable pointing to the created message) :

  etl::send_message(router, static_cast<const etl::imessage&>(m1));
  etl::send_message(router, static_cast<const etl::imessage&>(Message1(2)));
  etl::send_message(router, static_cast<const etl::imessage&>(m2));
  etl::send_message(router, static_cast<const etl::imessage&>(Message2(3.4)));
  etl::send_message(router, static_cast<const etl::imessage&>(m3));
  etl::send_message(router, static_cast<const etl::imessage&>(Message3("World")));
  etl::send_message(router, static_cast<const etl::imessage&>(Message4()));
 

Then the output is as expected :

Queueing message 1
Queueing message 1
Queueing message 2
Queueing message 2
Queueing message 3
Queueing message 3
Ignoring message 4

Processing message 1
  Received message 1 : '1'
Processing message 1
  Received message 1 : '2'
Processing message 2
  Received message 2 : '1.2'
Processing message 2
  Received message 2 : '3.4'
Processing message 3
  Received message 3 : 'Hello'
Processing message 3
  Received message 3 : 'World'
@aw-engineer
Copy link

I also see this with

  • ubuntu 22.04
  • gcc 11.4.0
  • -std=gnu++14

@jwellbelove
Copy link
Contributor

The issue is the line the using Base_t::receive; in examples\QueuedMessageRouter\QueuedMessageRouter.cpp

With it there, the compiler selects the base template member function, instead of the top level virtual function. The template member functions were added a while ago to enable more efficient calls when using concrete message types.

I have removed it from the example code.

@bizulk
Copy link
Author

bizulk commented Nov 30, 2024

Hello.
indeed, that works with this instruction removed, .
I was confused by this instruction. Could you explain why was this instructions added in the past ?
thanks.

@jwellbelove
Copy link
Contributor

It's used to give visibility of a base class function that been overloaded by the derived.
In the original code, before the introduction of the templated member functions in the base class, it was actually unnecessary.
After the new code was added, the base class template functions were made visible by the using, and the compiler decided that they were a better fit than the derived class's virtual receive function, so it called that one instead.

jwellbelove added a commit that referenced this issue Dec 4, 2024
…re-not-sent-to-queue' into development

# Conflicts:
#	test/test_message_router.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

3 participants