Registering a workflow with a remote Cadence server: Any examples - uber-cadence

How does one go about registering the workflows with a remote Cadence Server? Almost all examples are pointing to a local server.
Thanks
Sanjay

Replying to my own question. Wouldn't have solved this without help from Matt Anger.
ClientOptions tOptions = ClientOptions.newBuilder().setHost(serverHostName).setPort(serverPort).build() ;
WorkflowServiceTChannel tChannel = new WorkflowServiceTChannel(tOptions);
WorkflowClientOptions clientOptions = WorkflowClientOptions.newBuilder().setDomain(serverDomain).build();
WorkflowClient wfClient = WorkflowClient.newInstance(tChannel,clientOptions);
WorkerFactoryOptions factoryOptions = WorkerFactoryOptions.newBuilder().build();
WorkerFactory factory = WorkerFactory.newInstance(wfClient,factoryOptions);
// the class referred to below is from the tutorial
Worker worker = factory.newWorker("HelloWorldTaskList",
WorkerOptions.newBuilder()
.setMaxConcurrentActivityExecutionSize(100)
.setMaxConcurrentWorkflowExecutionSize(100)
.build());
worker.registerWorkflowImplementationTypes(HelloWorldImpl.class);
factory.start();

Related

Cadence Java client - Worker.Factory cannot be resolved

I am following the samples given in the java client sdk. Specifically
https://github.com/uber/cadence-java-samples/blob/master/src/main/java/com/uber/cadence/samples/hello/HelloWorkerSetup.java
Compiler is not able to resolve
Worker.Factory
I have tried to look in the client SDK code but I cannot seem to get past this error.
Has something changed in how workflows have to be registered?
Thanks
Sanjay
ClientOptions tOptions = ClientOptions.newBuilder().setHost(serverHostName).setPort(serverPort).build() ;
WorkflowServiceTChannel tChannel = new WorkflowServiceTChannel(tOptions);
WorkflowClientOptions clientOptions = WorkflowClientOptions.newBuilder().setDomain(serverDomain).build();
WorkflowClient wfClient = WorkflowClient.newInstance(tChannel,clientOptions);
WorkerFactoryOptions factoryOptions = WorkerFactoryOptions.newBuilder().build();
WorkerFactory factory = WorkerFactory.newInstance(wfClient,factoryOptions);

Add proxy to PhantomJSDriver (Selenium C#)

I'd like to listen to traffic generated by phantomjs selenium driver in c#. The below code does not work unfortunately!
PhantomJSOptions phoptions = new PhantomJSOptions();
phoptions.AddAdditionalCapability("proxy", "http://localhost:9999");
driver = new PhantomJSDriver(phoptions);
can anyone help me what's wrong with it!
Thanks in advance
Proxy proxy = new Proxy();
proxy.HttpProxy = string.Format("127.0.0.1:9999");
var service = PhantomJSDriverService.CreateDefaultService();
service.ProxyType = "http";
service.Proxy = proxy.HttpProxy;
IWebDriver driver = new PhantomJSDriver(service);
Some quick testing showed this work for me.
You can use the CapabilityType class to set the proxy capability. Here is a modified version of your code above:
PhantomJSOptions phoptions = new PhantomJSOptions();
phoptions.AddAdditionalCapability(CapabilityType.Proxy, "http://localhost:9999");
driver = new PhantomJSDriver(phoptions);
This worked for me. Arran's answer did not work for me. For some reason, my PhantomJSDriverService class did not have a ProxyType or Proxy member.

Hosting a self-hosted WF in IIS

Does anyone know if it's possible to host a self-hosted WorkflowServiceHost application in IIS without turning it into a XAMLX file? If so, how?
Furthermore, does anyone have any good guidelines for deploying XAMLX files in general to IIS 7?
Thanks in advance
You can do the same basic thing by writing your own hosting engine instead of the XAMLX one. You can then load applications via ASP.NET, but have complete control on it's lifespan/lifecycle.
You have to create your own host to load the .XAML workflows into something like a WorkflowApplication and manage the lifespan of that workflow. It looks something like this:
private SqlWorkflowInstanceStore _InstanceStore { get; private set; }
private InstanceHandle _MyInstanceHandle { get; private set; }
_InstanceStore = new SqlWorkflowInstanceStore(DataStore.ConnectionString.Replace("MultipleActiveResultSets=True", "MultipleActiveResultSets=False"));
_InstanceStore.HostLockRenewalPeriod = new TimeSpan(0, 0, 30);
_InstanceStore.InstanceEncodingOption = InstanceEncodingOption.None;
_InstanceStore.InstanceLockedExceptionAction = InstanceLockedExceptionAction.BasicRetry;
_InstanceStore.InstanceCompletionAction = InstanceCompletionAction.DeleteNothing;
_MyInstanceHandle = _InstanceStore.CreateInstanceHandle();
var CreateOwnerCommand = new CreateWorkflowOwnerCommand();
var MyView = _InstanceStore.Execute(_MyInstanceHandle, CreateOwnerCommand, TimeSpan.FromSeconds(30));
_InstanceStore.DefaultInstanceOwner = MyView.InstanceOwner;
WorkflowApplication ThisApplication = null;
if (parameters == null)
ThisApplication = new WorkflowApplication(activity);
else
ThisApplication = new WorkflowApplication(activity, parameters);
ThisApplication.PersistableIdle = e => PersistableIdleAction.Unload;
ThisApplication.InstanceStore = this.InstanceStore;
ThisApplication.Run();
There is a bit more to it then just the above, but it gives the basic concepts of how it would work.
EDIT (3/23/2011)
If anyone wants a copy of the basic code to do this, find a way to contact me.

WCF namedpipe callback timeout exception

I am using WCF for sending and getting data to and from 2 different win form applications running in the same machine. I am using namedpipe and duplexchannel. My client side implementation is shown below.
InstanceContext myContext = new InstanceContext(this);
NetNamedPipeBinding nb = new NetNamedPipeBinding();
nb.MaxBufferPoolSize = 5000000;
nb.MaxBufferSize = 500000;
nb.MaxReceivedMessageSize = 500000;
nb.ReceiveTimeout = TimeSpan.FromMinutes(5);
DuplexChannelFactory<IService> myProxy = new DuplexChannelFactory<IService>(myContext, nb, new EndPointAddress("net.pipe://localhost/MyService"));
IService myServiceClient = myProxy.CreateChannel();
And Server side implementation is shown below:
NetNamedPipeBinding np = new NetNamedPipeBinding();
np.MaxBufferPoolSize = 5000000;
np.MaxBufferSize = 500000;
np.MaxReceivedMessageSize = 500000;
host.AddServiceEndpoint(typeof(IService), np, "net.pipe://localhost/MyService");
host.OpenTimeout = TimeSpan.FromMinutes(5);
host.CloseTimeout = TimeSpan.FromMinutes(5);
host.Open();
I can pass about 100 object collection (ObservableCollection<Customer>) from 1 application through callback to other app. But if I make it 1000 or greater objects, the following Timeout Exception error occurs.
The write to the pipe did not complete
within the allotted timeout of
00:00:00. The time allotted to this
operation may have been a portion of a
longer timeout.
What is the fault in my code ? Please help me to overcome this issue.
Thanks in advance...
Looks like this question was also asked and answered here:
http://social.msdn.microsoft.com/Forums/eu/wcf/thread/38926593-8ea6-481d-8c43-072b73292f6a

Does WCF support WS-Eventing?

I know WCF supports many WS-* protocols but WS-Eventing does seem to be listed.
I do know that WCF has a pub/sub model, but is it WS-Eventing compliant?
I seem to remember reading about this on CodeProject a while ago.
Sorry I can't help more, but this is the article by Roman Kiss.
At least with WCF4 you can simply create a wsdl client by importing the WS-Eventing WSDL (with a soap binding). It requires a duplex binding so either http-duplex or simple tcp should work. The problem is adding the correct callback. For us this did the trick
Subscribe s = new Subscribe();
(s.Delivery = new DeliveryType()).Mode = "http://schemas.xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push";
XmlDocument doc = new XmlDocument();
using (XmlWriter writer = doc.CreateNavigator().AppendChild())
{
EndpointReferenceType notifyTo = new EndpointReferenceType();
(notifyTo.Address = new AttributedURI()).Value = callbackEndpoint.Uri.AbsoluteUri;
XmlRootAttribute notifyToElem = new XmlRootAttribute("NotifyTo");
notifyToElem.Namespace = "http://schemas.xmlsoap.org/ws/2004/08/eventing";
XmlDocument doc2 = new XmlDocument();
using (XmlWriter writer2 = doc2.CreateNavigator().AppendChild())
{
XmlRootAttribute ReferenceElement = new XmlRootAttribute("ReferenceElement");
foreach(AddressHeader h in callbackEndpoint.Headers)
{
h.WriteAddressHeader(writer2);
}
writer2.Close();
notifyTo.ReferenceParameters = new ReferenceParametersType();
notifyTo.ReferenceParameters.Any = notifyTo.ReferenceParameters.Any = doc2.ChildNodes.Cast<XmlElement>().ToArray<XmlElement>();
}
new XmlSerializer(notifyTo.GetType(), notifyToElem).Serialize(writer, notifyTo);
}
(s.Delivery.Any = new XmlElement[1])[0] = doc.DocumentElement;
(s.Filter = new FilterType()).Dialect = "http://schemas.xmlsoap.org/ws/2006/02/devprof/Action";
(s.Filter.Any = new System.Xml.XmlNode[1])[0] = new System.Xml.XmlDocument().CreateTextNode("http://www.teco.edu/SensorValues/SensorValuesEventOut");
SubscribeResponse subscription;
try
{
Console.WriteLine("Subscribing to the event...");
//Console.ReadLine();
subscription = eventSource.SubscribeOp(s);
}
There is no native pub/sub model in WCF 3.0, however there are a few options.
- The Roman Kiss article Ash found.
- There is a lot of other patterns you could implement (covered in MSDN Mag)
- Juval Lowy has two framework implementations you can download on his site at IDesign
- Lastly what I am using currently to mimic this with little overhead is MSMQ.