Unity resolves WCFServiceClient and closing the WCFServiceclient - unity-container

We are using unity to resolve the WCFService and the good practice of WCF says close the client once done.
But if we are using unity when and how to close WCFServiceClient?

I assume that unity provides a proxy to you? Can you use a using statement on the get from unity?
using(var proxy = GetProxyFromUnit()){
...
}
Type of thing?

Related

Grunt+Bower: dependency to another local project

I have two local Grunt+Bower-projects with typical build and watch/serve tasks:
Client contains the client to be publicly released
AdminClient is an extension to client intended for internal administration use
AdminClient should re-use Client code and build-result. watch/serve must behave transparently for any change in Client and AdminClient.
How can I do this with Grunt+Bower?
It is a basic problem solved in C# with project dependency and in java typically with maven sub-modules.
You can have the Client configuration in a separate file that you extend in the AdminClient.
var common = require("common.js");
...
grunt.initConfig(common.config);

How to check if a GLXcontext is remote or local

I'm experiencing problems since I'm calling cuGLGetDevices() on an application which uses the glXGetCurrentContext (https://www.opengl.org/sdk/docs/man2/xhtml/glXGetCurrentContext.xml) function to query an OpenGL context. The context must be local and not remote via ssh for my app to work properly.
Is there any way I can detect if the context is remote or local?
You need to use glXIsDirect function

How to avoid DTC when using PersistenceIOParticipant in WF4.0?

I am using PersistenceIOParticipant in WF4.0 to save something into database together with the persistence of the workflow instance. I have no idea that how to use the same connection object with the workflow persistence and I am forced to use the distributed transaction. Are there any ways to avoid using DTC?
I found the WF4 Sample project "WorkflowApplication ReadLine Host" useful
to see an example of persistenceIOParticipant in action.
I toggled the booleans in the constructor to verify that a transaction was being used and that
MSDTC was required.
See http://msdn.microsoft.com/en-us/library/dd764467.aspx
If using SQL Server 2008+, then it shouldn't matter if multiple connections are required. After using reflector on the SqlWorkflowInstanceStore, I discovered it was setting some additional properties on the connection string. Here is the code it uses to create a connection string:
SqlConnectionStringBuilder builder2 = new SqlConnectionStringBuilder(connectionString);
builder2.AsynchronousProcessing = true;
builder2.ConnectTimeout = (int)TimeSpan.FromSeconds(15.0).TotalSeconds;
builder2.ApplicationName = "DefaultPool";
SqlConnectionStringBuilder builder = builder2;
return builder.ToString();
I verified with profiler that MSDTC is not involved when using a custom IO participant and this connection string code. Don't forget to pass true to the base PersistenceIOParticipant constructor and flow Transaction.Current appropriately. Obviously, Microsoft could change that at anytime so use at your own discretion.

One Flex client connecting to two webapps using BlazeDS - Detected duplicate HTTP-based FlexSessions

I have a flex application that communicates via BlazeDS with two webapps running inside a single instance of Tomcat.
The flex client is loaded by the browser from the first webapp and all is well. However on the initial call to the second webapp the client receives the following error:
Detected duplicate HTTP-based FlexSessions, generally due to the remote host disabling session cookies. Session cookies must be enabled to manage the client connection correctly.
Subsequent calls to the same service method succeed.
I've seen a few posts around referring to the same error in the context of two flex apps calling a single webapp from the same browser page, but nothing which seems to help my situation - so I'd be very grateful if anyone could help out....
Cheers, Mark
Three potential solutions for you:
I found once that if I hit a remote object before setting up a messaging channel then the CientID would get screwed up. Try to establish an initial messaging channel once the application loads, and before any remote object calls are made.
Flash Builder's network monitoring tool can cause some problems with BlazeDS. I set up a configuration option on application load that checks to see if I'm in the dev environment (it is called just before setting up my channel from #1). If I'm in dev, I assign a UID manually. For some reason this doesn't take well outside the dev environment... been awhile since I set it all up so I can't remember the finer points as to why:
if (!(AppSettingsModel.getInstance().dev))
FlexClient.getInstance().id = UIDUtil.createUID();
BlazeDS by default only allows for a single HTTP session to be setup per client/browser. In my streaming channel definitions I added the following to allow for additional sessions per browser:
<channel-definition id="my-secure-amf-stream" class="mx.messaging.channels.SecureStreamingAMFChannel">
<endpoint url="https://{server.name}:{server.port}/FlexClient/messagebroker/securestreamingamf"
class="flex.messaging.endpoints.SecureStreamingAMFEndpoint"/>
<properties>
<add-no-cache-headers>false</add-no-cache-headers>
<idle-timeout-minutes>0</idle-timeout-minutes>
<max-streaming-clients>10</max-streaming-clients>
<server-to-client-heartbeat-millis>5000</server-to-client-heartbeat-millis>
<user-agent-settings>
<user-agent match-on="MSIE" kickstart-bytes="2048" max-streaming-connections-per-session="3" />
<user-agent match-on="Firefox" kickstart-bytes="2048" max-streaming-connections-per-session="3" />
</user-agent-settings>
</properties>
Problem: Duplicate session errors when flex.war and Livecycle.lca files are hosted in separate JVMs on WebSphere Server.
Solution:
Inside the command file for the event, set FlexClientId to null in execute method before calling remote service (Java method or LC Process).
Guess this approach can be used in other scenarios as well to prevent Duplicate session errors.
EventCommand.as file
—————————–
import mx.messaging.FlexClient;
//other imports as per your code
public function execute(event:CairngormEvent):void
{
var evt:EventName = event as EventName ;
var delegate:Delegate = new DelegateImpl(this as IResponder);
//***set client ID to null
FlexClient.getInstance().id = null;
delegate.functionName(evt.data);
}

How to use AIR 2.0 NativeProcess API with Java?

How do you use this great new API in connection with Java? Do you use just pure native process API like nativeProcess.standardInput.write() and nativeProcess.standardOutput.read() with which you cannot debug Java side neither invoke remote java method. Or you are using some library that leverages remote method invocation such as flerry lib but that also cannot debug Java side? Or maybe you are using Merapi with which you can debug but cannot remotely invoke Java method? I'm asking this because this is maybe the most important question regarding this API and its ease of use.
It sounds like your reservations have to do with being able to debug the Java process. This is not really an issue. You can use the NativeProcess API to kick off a Java process with arguments that will cause it to be externally debuggable. For example:
var processArgs:Vector.<String> = new Vector.<String>();
processArgs.push("-Xdebug");
processArgs.push("-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n");
This will allow your Java process to be remote debuggable. You can then connect to it from Eclipse or Netbeans once the process has started. If the code in the Java process is linked to an active Eclipse/Netbeans project, you can do linewise debugging like you would of any other Java application.
-Raj
You can use NativeProcess to execute java.exe and pass it the right parameters to execute a java application.
You cannot use NativeProcess to run random java code from a jar file.
Having used both of them, you can debug the JVM with MerAPI or NativeProcess API.
Prior to AIR2.0, I used merapi to communicate over the network to a java process.
I would much prefer to use the NativeProcess launcher now, with MerAPI we were hacking
ugly marshalling code. Debugging the network payloads was a pin via merapi.
Using NativeProcess API is easy -
var myForkedExe:NativeProcessStartupInfo = new NativeProcessStartupInfo();
myForkedExe.executable = ;
...
I am not sure I understand what you mean by can not invoke remote Java methods with merapi.
That's exactly what I have been doing. Debugging is easy, just set the JPDA args and attach any JAVA debugger.
You could use Flerry to launch and communicate with java processes.
You can use var file:File = new File("/usr/bin/java"); and pass parameters to the Java-file with a Vector of arguments. E.g.
var arguments:Vector.<String> = new Vector.<String>;
arguments.push("-jar");

Resources