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

Is it possible that this bridge replays old messages ? #2

Closed
ramukima opened this issue Jan 19, 2016 · 1 comment
Closed

Is it possible that this bridge replays old messages ? #2

ramukima opened this issue Jan 19, 2016 · 1 comment
Assignees
Labels

Comments

@ramukima
Copy link

Server

package test;

import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.bridge.BridgeOptions;
import io.vertx.ext.bridge.PermittedOptions;
import io.vertx.ext.eventbus.bridge.tcp.TcpEventBusBridge;

public class BridgeTest {
    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();
        TcpEventBusBridge bridge = TcpEventBusBridge.create(
                vertx,
                new BridgeOptions()
                .addOutboundPermitted(new PermittedOptions().setAddress("out")));
        bridge.listen(7000, res -> vertx.setPeriodic(2*1000, new Handler<Long>() {
            @Override
            public void handle(Long timer) {
                vertx.eventBus().send("out", new JsonObject().put("now", System.currentTimeMillis()));
            }
        }));
    }
}

Client

var EventBus = require('../lib/tcp-vertx-eventbus');
    var eb = new EventBus('localhost', 7000);
    eb.onerror = function (err) {
      console.error(err);
    };

    eb.onopen = function () {
      // send a echo message
      eb.registerHandler("out", function (err, msg) {
          console.log("message:" + JSON.stringify(msg));
      });
    };

Result

bash-3.2$ node test/app.js 
message:{"type":"message","address":"out","headers":{},"body":{"now":1453190899736}}
message:{"type":"message","address":"out","headers":{},"body":{"now":1453190899736}}
message:{"type":"message","address":"out","headers":{},"body":{"now":1453190899736}}
message:{"type":"message","address":"out","headers":{},"body":{"now":1453190899736}}
message:{"type":"message","address":"out","headers":{},"body":{"now":1453190899736}}

Notice the value of 'now' in the message received by the client.

@pmlopes pmlopes self-assigned this Jan 19, 2016
@pmlopes pmlopes added the bug label Jan 19, 2016
pmlopes added a commit that referenced this issue Jan 19, 2016
Fixes #2: the node library was not cleaning the buffer after reading …
@ramukima
Copy link
Author

Verified. Works now, thanks for fixing this.

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

No branches or pull requests

2 participants