Code Monkey home page Code Monkey logo

Comments (2)

bennidi avatar bennidi commented on June 12, 2024

I am not sure if I understand correctly but if you are trying to implement logic in which the publisher and handler run in the same thread context then this is hard to do with async messages. Definitely requires custom synchronization logic. One direction would be to provide Mbassador with the ThreadFactory for the async handlers and implement it in such a way that the handler has access to it. However, this smells like bad design. Can you elaborate your use case a bit more? Maybe there is a better way to achieve what you have in mind.

from mbassador.

Gerry33 avatar Gerry33 commented on June 12, 2024

Hi Benjamin and thanks for taking care (with my apologies for the late reply due to heavy work load)

The problem is that I'm bound to some framework. I start my servlet with a Callable/Runnable like this:

class myClass {

// this is my framework call . I have to stick with this. 
Future <?> myfuture = Application.getContext()-> () 	

 // now herein I'm happy within my framework and can do what I need 

});
// but it stops here 

@Handler
public void MyHandler ( ...) {
	// here I'm outside  and I have no access to the  framework 
}
} // end class 

What I want:

class MyClass {

public void MyClass() {

Future <?> myfuture = Application.getContext()-> () 

	@Handler
	public void refresh ( final GUIUpdates msg) {
	
	
	}
});
}

OR:

class MyClass {
public void MyClass() {

Future <?> myfuture = Application.getContext()-> () 
		// something like  a blocking call 
		Message m = net.engio.mbassy.WaitForMessage (); 
	}

});
}

I agree with your remark that the latter is bad design, lets call it ugly.

Problem is that a handler can only be defined on class level.
I will therefore try to remove the lambda call and replace it with a runnable class and try to place the handler there.
If you have some better idea, I would be very happy to hear from you.

Thanks for your work on 'mbassador'.

Gerry

from mbassador.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.