How to dynamically add New Proxy service in Membrane Proxy

72 views
Skip to first unread message

abhinav rastogi

unread,
Jan 25, 2016, 3:26:44 AM1/25/16
to membrane-monitor
HI all ,

I am trying to create a wrapper over membrane proxy. 

What i wish to do , 
1. Add Service Proxies / proxies dynamically in a running instance of Membrane 
2. I do not want to use Proxies.xml to add new service proxies dynamically but use code to initialize the objects.  
2. Do not want to restart the membrane everytime new service proxy is added , similar to hot deployment

KIndly guide me as i am new to this .


Regards
Abhinav

Thomas Bayer

unread,
Jan 25, 2016, 4:06:13 AM1/25/16
to membrane...@googlegroups.com
Hi Abhinav,
you can use the Membrane Java API and embed Membrane into your program:

http://www.membrane-soa.org/service-proxy-doc/4.1/embedding-router-java.htm

Cheers,
Thomas


Am 25.01.16 um 09:02 schrieb abhinav rastogi:
--
You received this message because you are subscribed to the Google Groups "membrane-monitor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to membrane-monit...@googlegroups.com.
To post to this group, send email to membrane...@googlegroups.com.
Visit this group at https://groups.google.com/group/membrane-monitor.
For more options, visit https://groups.google.com/d/optout.

abhinav rastogi

unread,
Jan 27, 2016, 2:46:41 AM1/27/16
to membrane-monitor
Thanks for the input , i tried using add and remove in the router object and Rule Manager object but when i am updating a Rule by replacing the current object with a new rule object. It is reflecting in the admin console but not redirecting ?? CAn some one please guide me as to what i am missing ??

Thomas Bayer

unread,
Jan 27, 2016, 3:47:13 AM1/27/16
to membrane...@googlegroups.com
Hi Abhinav,
to help you I need more details. What do you mean here by not redirecting? Can you post your setup, how it behaves and how it should behave?

Cheers,
Thomas

Am 27.01.16 um 08:46 schrieb abhinav rastogi:
--
Message has been deleted

abhinav rastogi

unread,
Jan 27, 2016, 4:37:11 AM1/27/16
to membrane-monitor
public static void updateSP()  {
String hostname = "*";
String method = "*";
String pathold = "^/sachin.*";
String pathnew = "^/abhinav.*";
int listenPort = 80;

Iterator<Rule> ruleIterator = router.getRuleManager().getRules().iterator();
while (ruleIterator.hasNext()) {
Rule rule = ruleIterator.next();
Rule ruleNew;
try {
ruleNew = rule.clone();

ruleNew.getKey().setPath(pathnew);
System.out.println("Before " + rule.getKey().getPath());
if (rule.getKey().getPath().equals(pathold)) {
router.getRuleManager().replaceRule(rule, ruleNew);
}
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

On Monday, January 25, 2016 at 9:26:44 AM UTC+1, abhinav rastogi wrote:

Thomas Bayer

unread,
Jan 27, 2016, 5:14:45 AM1/27/16
to membrane...@googlegroups.com
Hi Abhinav,
the code below should not remove the admin service proxy. Do you do a router.init(), restart or something similiar?

Can you printout the rules and their configuration, then change the rule and again printout the configuration?

Cheers,
Thomas

Am 27.01.16 um 10:35 schrieb abhinav rastogi:
I am trying to do this 

public static void updateSP()  {
String hostname = "*";
String method = "*";
String pathold = "^/sachin.*";
String pathnew = "^/abhinav.*";
int listenPort = 80;

Iterator<Rule> ruleIterator = router.getRuleManager().getRules().iterator();
while (ruleIterator.hasNext()) {
Rule rule = ruleIterator.next();
Rule ruleNew;
try {
ruleNew = rule.clone();

ruleNew.getKey().setPath(pathnew);
System.out.println("Before " + rule.getKey().getPath());
if (rule.getKey().getPath().equals(pathold)) {
// router.add((ServiceProxy)ruleNew);
// router.init();
// router.getRuleManager().removeRule(rule);
router.getRuleManager().replaceRule(rule, ruleNew);
}
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

but it is also removing admin Service Proxy.

On Monday, January 25, 2016 at 9:26:44 AM UTC+1, abhinav rastogi wrote:
--

Tobias Polley

unread,
Jan 27, 2016, 5:19:07 AM1/27/16
to membrane-monitor
Hi Abhinav,

have a look at EtcdBasedConfigurator.java . It also dynamically adds and removes serviceProxies.

Best,
Tobias
Reply all
Reply to author
Forward
0 new messages