Skip to content

feat: implement direct message passing on a cluster#99

Open
kenkalang wants to merge 60 commits into
mainfrom
feature/direct-message-passing
Open

feat: implement direct message passing on a cluster#99
kenkalang wants to merge 60 commits into
mainfrom
feature/direct-message-passing

Conversation

@kenkalang

Copy link
Copy Markdown

Proposed Changes

Implement direct message passing node to node to reduce latency

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes issue #XXXX)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (correction or otherwise)
  • Cosmetics (whitespace, styles...)
  • DevOps (Build scripts, pipelines...)

Checklist

  • I have read the CODE_OF_CONDUCT.md document
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if needed)
  • Any dependent changes have been merged and published in related repositories
  • I have updated changelog (At the bottom of the release version)
  • I have squashed all my commits into one before merging

@kenkalang kenkalang closed this Apr 17, 2026
@kenkalang kenkalang reopened this Apr 27, 2026
@kenkalang kenkalang force-pushed the feature/direct-message-passing branch 5 times, most recently from 3532e68 to e87d5c3 Compare April 29, 2026 05:59
Comment thread apps/vmq_server/src/vmq_health_http.erl Outdated
Comment thread apps/vmq_server/src/vmq_cluster_com.erl
Comment thread apps/vmq_server/src/vmq_message_store.erl Outdated
Comment thread apps/vmq_server/test/vmq_cluster_test_utils.erl Outdated
Comment thread apps/vmq_server/test/vmq_cluster_SUITE.erl
@kenkalang kenkalang force-pushed the feature/direct-message-passing branch 4 times, most recently from af2dadb to 068c9fe Compare May 6, 2026 08:33
@kenkalang kenkalang force-pushed the feature/direct-message-passing branch 4 times, most recently from 2e15c4a to 709c51e Compare May 19, 2026 09:12
@kenkalang kenkalang force-pushed the feature/direct-message-passing branch 3 times, most recently from f062c4f to e3e77a8 Compare May 22, 2026 10:08
shared_subs_prefer_local_policy_test_with_local_caching/1,
shared_subs_local_only_policy_test/1,
shared_subs_local_only_policy_test_with_local_caching/1,
shared_subs_random_policy_dead_node_message_reaper_test/1,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this test was removed, put this behind config while running if it requires redis.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, please check latest commit

Comment thread apps/vmq_server/src/vmq_cluster_mon.erl Outdated
_ -> false
end,
vmq_state_store_backend:del_reaper(Node),
ets:insert(?VMQ_CLUSTER_STATUS, {Node, true, 0}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this insert is always getting overridden below, remove if not needed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is deleted

-spec delete(_) -> 'true' | {'error', 'redis_error'}.
delete(SubscriberId) ->
case vmq_state_store_backend:msg_store_delete(SubscriberId) of
case

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you adding this back? If you need to change the Redis call, then please change the parent call from the vmq_state_store_backend > vmq_redis_store & vmq_noop_store.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

case vmq_state_store_backend:msg_store_pop(SubscriberId, MsgRef) of
-spec delete(subscriber_id(), _) -> 'true' | {'error', 'redis_error'}.
delete(SubscriberId, _MsgRef) ->
case

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you adding this back? If you need to change the Redis call, then please change the parent call from the vmq_state_store_backend > vmq_redis_store & vmq_noop_store.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

ets:insert(?OFFLINE_MESSAGES, {count, binary_to_integer(OfflineMsgCount)});
{error, _} ->
{error, not_supported}
{error, redis_error}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share the reason behind the error message change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will revert this

Comment thread apps/vmq_server/src/vmq_cluster_node_sup.erl
Comment thread apps/vmq_server/src/vmq_cluster_mon.erl
Comment thread apps/vmq_server/src/vmq_cluster_mon.erl Outdated
Comment thread vars.config
Comment thread apps/vmq_server/test/vmq_cluster_SUITE.erl
@kenkalang kenkalang force-pushed the feature/direct-message-passing branch from 17648d8 to 4570bc6 Compare June 26, 2026 06:13
@kenkalang kenkalang force-pushed the feature/direct-message-passing branch from 77707cc to 2c9e003 Compare June 28, 2026 11:25

stop(_State) ->
stop(State) ->
%% Catch and log the termination event using VerneMQ's native Lager logger

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it only for debugging and testing in staging env? Do we need this in prod?

{validators, ["buffer_size_validator"]}
]}.

{mapping, "listener.vmq.$name.buffer_sizes", "vmq_server.listeners",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this config used?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used on both receiver and sender sides with the values being [send buf, rec buf, erl buffer]. Currently we're using default value on receiver side and default OS value on sender side

{datatype, string},
hidden
]}.
{mapping, "listener.vmqs.mountpoint", "vmq_server.listeners", [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ssl connection configurations are not complete. Let's skip ssl for now.

We can add support for SSL later when required.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let's put it as improvement later

"cache_shared_subscriptions_locally"
"cache_shared_subscriptions_locally",
"direct_message_passing",
"cluster_node_liveness_rpc_timeout"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this as runtime configurable?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for cluster_node_liveness_rpc_timeout yes we don't need this, will remove this as part as clean up

"graphite_interval",
"graphite_include_labels",
"shared_subscription_policy",
"remote_enqueue_timeout",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this as runtime configurable?

Comment thread vars.config
{cluster_default_port, 44053}.
{http_default_ip, "127.0.0.1"}.
{http_default_port, 8888}.
{metadata_plugin, vmq_plumtree}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not using this as well. Can you just verify and remove it if it is unused?

@kenkalang kenkalang force-pushed the feature/direct-message-passing branch from edf5472 to a0fa828 Compare July 13, 2026 12:24
@kenkalang kenkalang force-pushed the feature/direct-message-passing branch from a0fa828 to 9d639f5 Compare July 13, 2026 16:38
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 this pull request may close these issues.

3 participants