Which Attribute Of The Queues is Referenced In Diverts? - jboss

The examples of diverts have the same name for the queue as the entry so I am not clear which I use for the divert reference. e.g.
<jms-destinations>
<jms-queue name="VendorQueue">
<entry name="queue/vendor"/>
<entry name="java:jboss/exported/queue/vendor"/>
<durable>false</durable>
</jms-queue>
</jms-destinations>
Is this correct?
jms-queue add --queue-address=monitoring --entries=queue/monitoring
/subsystem=messaging/hornetq-server=default/divert=my-divert:add(divert-address=jms.queue.VendorQueue,forwarding-address=jms.queue.monitoring,exclusive=false)
i.e. is the divert-address supposed to be jms.queue.VendorQueue or jms.queue.vendor?

To get the correct divert-address you need to run this
/subsystem=messaging/hornetq-server=default:read-children-names(child-type="jms-queue")
Then prefix jms.queue
e.g.
{
"outcome" => "success",
"result" => [
"VendorQueue",
"monitoring"
]
}
becomes
jms.queue.VendorQueue
In reference to the xml, the jms-queue name is the attribute you reference not the entry name.

Related

Sulu: error when trying to use custom data provider

I'm following docs from here: https://docs.sulu.io/en/2.2/cookbook/smart-content-data-provider.html
Trying to make custom data provider for my custom entity type "MatchEvent":
I did it how it's explained here. Since I have services.yaml file I defined those 2 like this:
app.match_event_repository:
class: App\Repository\MatchEventRepository
factory: ['#doctrine', 'getRepository']
arguments:
- Symfony\Bridge\Doctrine\ManagerRegistry
app.smart_content.data_provider.matchevent:
class: App\SmartContent\MatchEventDataProvider
arguments: ['#app.match_event_repository', '#sulu_core.array_serializer', '#request_stack' ]
tags: [{name: 'sulu.content.type', alias: 'smart_matchevent_selection'}]
So, if I understood well, after that I should have my custom content data provider named "smart_matchevent_selection" and I can use it like this:
<property name="match" type="smart_content">
<meta>
<title lang="en">Match</title>
<title lang="de">Match</title>
</meta>
<params>
<param name="provider" value="smart_matchevent_selection"/>
</params>
</property>
But when I try to edit page containing this field I get error:
Missing parameter token in Sulu\Bundle\PreviewBundle\Controller\PreviewController
Exception is triggered at project/vendor/sulu/sulu/src/Sulu/Bundle/PreviewBundle/Controller/PreviewController.php:
public function stopAction(Request $request): Response
{
$this->preview->stop($this->getRequestParameter($request, 'token', true));
return new JsonResponse();
}
What I'm doing wrong here?
If you carefully look at the service definition of the SmartContentDataProvider in the documentation, you will notice that the tag should be {name: 'sulu.smart_content.data_provider', alias: 'match_events'} instead of {name: 'sulu.content.type', alias: 'smart_matchevent_selection'} ...
Then you can use it like <param name="provider" value="match_events"/>

NameNotFoundException: connecting to remote queue via logstash

I have a deployed queue on JBoss EAP 7.1 (defined in standalone.xml) that is managed by ActiveMQ Artemis (name of the module xmlns="urn:jboss:domain:messaging-activemq:2.0") and at the same time I want to connect to that queue with the JMS plugin in logstash (with JNDI) for consuming the messages that are sent by the deployed app on my JBoss server, but when I try I get a NameNotFoundException for the connection factory (the property jndi_name in the logstash conf file).
I tried to find the default connection factories JNDI entries but even then it didn't work.
So i want to know if the connection factories are created by the message broker or exist by default for the client? Because if I'm not mistaken, the connection factory is the only way to connect to the broker and the queue and correct if I'm wrong please but they have to exist by default for the client.
I hope you can help me guys here is my logstash conf file:
input {
jms {
# Logstash Configuration Settings.
include_header => false
include_properties => false
include_body => true
use_jms_timestamp => false
destination => "AuditTrailMDB"
pub_sub => false
# JNDI Settings
jndi_name => 'queueConnectionFactory'
jndi_context => {
'java.naming.factory.initial' => 'org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory'
'java.naming.security.principal' => 'admin'
'java.naming.provider.url' => 'tcp://localhost:5445?type=QUEUE_CF'
'java.naming.security.credentials' => 'admin'
}
# Jar files to be imported
require_jars=> ['/home/Alternant/logstash/dependencies/jboss-client.jar',
'/home/Alternant/logstash/dependencies/artemis-ra.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-core-impl.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-core-api.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-common-api.jar']
}
}output{
stdout{}
}
and here is my queue definition in the standalone.xml:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
<server name="default">
<security-setting name="#">
<role consume="true" create-non-durable-queue="true" delete-non-durable-queue="true" name="guest" send="true"/>
</security-setting>
<address-setting dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" message-counter-history-day-limit="10" name="#" page-size-bytes="2097152"/>
<http-connector endpoint="http-acceptor" name="http-connector" socket-binding="http"/>
<http-connector endpoint="http-acceptor-throughput" name="http-connector-throughput" socket-binding="http">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0">
<param name="buffer-pooling" value="false"/>
</in-vm-connector>
<remote-connector name="netty" socket-binding="remote-messaging"/>
<http-acceptor http-listener="default" name="http-acceptor"/>
<http-acceptor http-listener="default" name="http-acceptor-throughput">
<param name="batch-delay" value="50"/>
<param name="direct-deliver" value="false"/>
</http-acceptor>
<in-vm-acceptor name="in-vm" server-id="0">
<param name="buffer-pooling" value="false"/>
</in-vm-acceptor>
<remote-acceptor name="netty" socket-binding="messaging"/>
<jms-queue entries="java:/jms/queue/ExpiryQueue" name="ExpiryQueue"/>
<jms-queue entries="java:/jms/queue/DLQ" name="DLQ"/>
<jms-queue entries="queue/clientPending" name="clientPending"/>
<jms-queue name="AuditTrailMDB" entries="queue/AuditTrailMDB"/>
<connection-factory connectors="in-vm" entries="java:/ConnectionFactory" name="InVmConnectionFactory"/>
<pooled-connection-factory connectors="netty" entries="java:jboss/exported/jms/RemoteConnectionFactory" name="RemoteConnectionFactory" user="admin" password="admin"/>
<pooled-connection-factory connectors="in-vm" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" name="activemq-ra" transaction="xa"/>
<connection-factory connectors="in-vm" entries="/ApplicationsQueueConnectionFactory" name="ApplicationsQueueConnectionFactory"/>
</server>
</subsystem>
...
<socket-binding name="messaging" port="5445"/>
...
log:
[WARN ][logstash.inputs.jms ][main] JMS Consumer Died {:exception=>"Java::JavaxNaming::NameNotFoundException", :exception_message=>"queueConnectionFactory", :backtrace=>["org.apache.activemq.artemis.jndi.ReadOnlyContext.lookup(org/apache/activemq/artemis/jndi/ReadOnlyContext.java:236)", "javax.naming.InitialContext.lookup(javax/naming/InitialContext.java:417)", "java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:498)", "org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:455)", "org.jruby.javasupport.JavaMethod.invokeDirect(org/jruby/javasupport/JavaMethod.java:316)", "home.Alternant.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.jruby_minus_jms_minus_1_dot_3_dot_0_minus_java.lib.jms.connection.initialize
There's a handful of things wrong with your configuration both for JBoss EAP and for Logstash.
Let's start with JBoss EAP...
First, you changed the default configuration of RemoteConnectionFactory to this:
<pooled-connection-factory connectors="netty" entries="java:jboss/exported/jms/RemoteConnectionFactory" name="RemoteConnectionFactory" user="admin" password="admin"/>
This is incorrect. A remote client cannot use a pooled-connection-factory, only a client in the same JVM as the application server can (e.g. an MDB which needs to send a message). You should use the default configuration instead:
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
Second, your AuditTrailMDB queue will not be available to remote clients. Here's its configuration:
<jms-queue name="AuditTrailMDB" entries="queue/AuditTrailMDB"/>
It needs a new JNDI entry in the java:jboss/exported/ namespace in order to be available to remote clients (e.g. like RemoteConnectionFactory has). Therefore you should use this:
<jms-queue name="AuditTrailMDB" entries="queue/AuditTrailMDB java:jboss/exported/AuditTrailMDB"/>
Now for Logstash...
First, you're using the wrong JNDI properties. The properties you're using are for the ActiveMQ Artemis JNDI implementation. Here's your current configuration:
jndi_context => {
'java.naming.factory.initial' => 'org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory'
'java.naming.security.principal' => 'admin'
'java.naming.provider.url' => 'tcp://localhost:5445?type=QUEUE_CF'
'java.naming.security.credentials' => 'admin'
}
This is incorrect. When ActiveMQ Artemis is embedded into JBoss EAP then EAP itself handles all the JNDI lookups. Therefore you should be using this configuration instead:
jndi_context => {
'java.naming.factory.initial' => 'org.wildfly.naming.client.WildFlyInitialContextFactory'
'java.naming.security.principal' => 'admin'
'java.naming.provider.url' => 'http-remoting://127.0.0.1:8080'
'java.naming.security.credentials' => 'admin'
}
This assumes, of course, that you've added the proper admin user to EAP.
Second, your connection factory JNDI name is incorrect. You're currently using this:
jndi_name => 'queueConnectionFactory'
You should be using this instead:
jndi_name => 'jms/RemoteConnectionFactory'
Third, the jars you're using are incorrect. Here's your current configuration:
require_jars=> ['/home/Alternant/logstash/dependencies/jboss-client.jar',
'/home/Alternant/logstash/dependencies/artemis-ra.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-core-impl.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-core-api.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-common-api.jar']
You don't need most of these at all. You can simplify your configuration by using the wildfly-client-all "uber" jar which is available here. Then your configuration would look like this:
require_jars=> ['/home/Alternant/logstash/dependencies/wildfly-client-all-7.1.0.GA-redhat-11.jar']

Apache Camel How to pass SOAP message from JMS queue to CXF endpoint

I am trying to create a Camel route that will:
Get JMS messages from a queue, the message body is a SOAP request.
Send the message to a cxf endpoint.
Put the response onto a response queue.
This is my code:
private void setupRequestRoute() {
from("jms:queue:input")
.setHeader(CxfConstants.OPERATION_NAME, simple("XXXXXX"))
.setHeader(CxfConstants.OPERATION_NAMESPACE, simple("XXXXXX"))
.log("Route headers : ${headers}")
.to("cxf:bean:myEndpoint")
.to("jms:queue:response")
.end();
}
Endpoint configuration:
<cxf:cxfEndpoint id="myServiceEndpoint"
address="http://localhost:8080/MyService/V2"
wsdlURL="schemas/MyService.wsdl"
xmlns:c="http://xxxx.xxxx/xxxxxxxx/XXX/MyService/V2">
<cxf:outFaultInterceptors>
<ref bean="interceptor.out.soap.fault"/>
</cxf:outFaultInterceptors>
<cxf:properties>
<entry key="schema-validation-enabled" value="true" />
<entry key="dataFormat" value="PAYLOAD" />
<entry key="defaultBus" value="true" />
<entry key="allowStreaming" value="false" />
</cxf:properties>
</cxf:cxfEndpoint>
I feel I've misunderstood something fundamental about camel works in this scenario. It appears to be the presence of the soap envelope that is causing this issue. I had presumed that camel would be able to take the raw soap message and convert it to the correct message format for the cxf endpoint.
Could someone explain to me how I can pass the SOAP request to the CXF endpoint?
2018-12-03 12:27:32,222 | ERROR | INPUT] | DefaultErrorHandler | 43 - org.apache.camel.camel-core - 2.16.4 | Failed delivery for (MessageId: ID:xxxxxxxxxxxx-46588-1543829293785-1:21:1:1:1
on ExchangeId: ID-xxxxxxxxxxxx-35264-1543835233229-2-1). Exhausted after delivery attempt: 1 caught: java.lang.IllegalArgumentException: The PayLoad elements cannot fit with the message parts of the BindingOpera
tion. Please check the BindingOperation and PayLoadMessage.
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)
[from.XS.to.xsb?dat] [from.XS.to.xsb?dat] [jms://queue:input ] [ 17]
[from.XS.to.xsb?dat] [setHeader7 ] [setHeader[operationName] ] [ 0]
[from.XS.to.xsb?dat] [setHeader8 ] [setHeader[operationNamespace] ] [ 0]
[from.XS.to.xsb?dat] [log6 ] [log ] [ 12]
[from.XS.to.xsb?dat] [to45 ] [cxf:bean:myEndpoint ] [ 3]
Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
Id ID-xxxxxxxxxxxx-35264-1543835233229-2-1
ExchangePattern InOut
Headers {breadcrumbId=ID:xxxxxxxxxxxx-46588-1543829293785-1:21:1:1:1, CamelRedelivered=false, CamelRedeliveryCounter=0, JMSCorrelationID=null, JMSCorrelationIDAsBytes=null, JMSDeliveryMode=2,
JMSDestination=queue://input, JMSExpiration=0, JMSMessageID=ID:xxxxxxxxxxxx-46588-1543829293785-1:21:1:1:1, JMSPriority=4, JMSRedelivered=false, JMSReplyTo=queue://response, JMSTimestamp=1543840052184, JMSType=null, JMSXGroupID=null, JMSXUserID=null, operationName=MyOperation, operationNamespace=MyOperationNameSpace}
BodyType String
Body <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://xxxx.xxxx/xxxxxxxx/xxx/xxxxxxxxxxxxxxxxxx/V2" xmlns:v21="http://xxxx.xxxx/xxxxxxxx/xxx/xxxxxx/V2">
<soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecur
ity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-xxxx"><wsse:Username>username</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-ws
s-username-token-profile-1.0#PasswordDigest">xxxx</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
xxxxx</wsse:Nonce><wsu:Created>2018-12-03T12:27:32.183Z</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header> <soapenv:Body> <v2:MyRequest>
...
...
</v2:MyRequest> </soapenv:Body></soapenv:Envelope>
]
Stacktrace
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.IllegalArgumentException: The PayLoad elements cannot fit with the message parts of the BindingOperation. Please check the BindingOperation and PayLoadMessage.
at org.apache.camel.component.cxf.CxfEndpoint$CamelCxfClientImpl.setParameters(CxfEndpoint.java:1189)[44:org.apache.camel.camel-cxf:2.16.4]
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:470)[57:org.apache.cxf.cxf-core:3.1.5]
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:416)[57:org.apache.cxf.cxf-core:3.1.5]
at org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:134)[44:org.apache.camel.camel-cxf:2.16.4]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[43:org.apache.camel.camel-core:2.16.4]
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:112)[46:org.apache.camel.camel-jms:2.16.4]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:555)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:515)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:485)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1103)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1095)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:992)[154:org.apache.servicemix.bundles.spring-jms:3.2.17.RELEASE_1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)[:1.8.0_181]
at java.lang.Thread.run(Thread.java:748)[:1.8.0_181]
You specify PAYLOAD data format, but according to the docs that is for soap:body processing. Can you XPath out the body into the current exchange, or do you need all the WSE headers?
Or try one of the other data formats MESSAGE (called RAW in later versions I think?) or CXF_MESSAGE sound like they are closer to what you're trying to achieve.

Extending Modx modResource schema errors

I'm trying to extend the modx modresource object, but keep getting errors & I can't seem to figure out why. It is related to the schema (I think) but everything looks correct.
Schema:
<?xml version="1.0" encoding="UTF-8"?>
<model package="extresource" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="modx_" version="1.0.0">
<object class="extResource" extends="modResource">
<composite alias="ResourceData" class="ResourceData" local="id" foreign="internalKey" cardinality="one" owner="local"/>
</object>
<object class="ResourceData" table="resource_data" extends="xPDOSimpleObject">
<field key="internalKey" dbtype="int" precision="11" phptype="integer" null="false" attributes="unsigned"/>
<field key="views" dbtype="int" precision="11" phptype="integer" null="true" />
<field key="starred" dbtype="int" precision="10" phptype="integer" null="false" />
<index alias="internalKey" name="internalKey" primary="false" unique="true" type="BTREE" >
<column key="internalKey" length="" collation="A" null="false" />
</index>
<aggregate alias="Resource" class="modResource" local="internalKey" foreign="id" cardinality="one" owner="foreign"/>
</object>
</model>
I'm testing it using:
$resource = $modx->getObject('modResource', 11112);
echo $resource->get('pagetitle'); //test I have the resource
$data = $resource->getOne('ResourceData');
The errors I get are:
Could not getOne: foreign key definition for alias ResourceData not
found. No foreign key definition for parentClass: modDocument using
relation alias: ResourceData
The table exists & has data, the package is registered in the modx extension packages. I've been over the schema many times & it looks right.
What is causing these errors?
You have to use the right object class in $modx->getObject. Otherwise you will get a modResource object, that does not know the extended object data and relationship.
$resource = $modx->getObject('extResource', 11112);
Does the resource you are loading have its class_key field set to extResource? That's needed for it to load the right resource object class.

Service Fabric specify fabric url

Is it possible to define which url a service uses instead of the standard fabric:/AppName/ServiceName?
I can't find if this is configurable or not on an application level.
Yes, you can change the name of the service in the ApplicationManifest.xml to something other than the name taken from the service's class name.
Short: just change the name attribute in ApplicationManifest.xml for that service to something else.
In code: If I have this service:
public interface IJustAnotherStatelessService : IService
{
Task<string> SayHelloAsync(string someValue);
}
internal sealed class JustAnotherStatelessService : StatelessService, IJustAnotherStatelessService
{
// Service implementation
}
Registered in Program.cs like this:
ServiceRuntime.RegisterServiceAsync("JustAnotherStatelessServiceType",
context => new JustAnotherStatelessService(context)).GetAwaiter().GetResult();
And in the ServiceManifest.xml for that service
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest ...>
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="JustAnotherStatelessServiceType" />
</ServiceTypes>
...
In the ApplicationManifest.xml you will get the suggested name:
<ApplicationManifest ...>
<DefaultServices>
<Service Name="JustAnotherStatelessService">
<StatelessService ServiceTypeName="JustAnotherStatelessServiceType" InstanceCount="[JustAnotherStatelessService_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>
This will give you an Uri to you service like
fabric:/app_name/JustAnotherStatelessService
Now, go ahead and change the name in the application manifest:
<ApplicationManifest ...>
<DefaultServices>
<Service Name="AwesomeService">
<StatelessService ServiceTypeName="JustAnotherStatelessServiceType" InstanceCount="[JustAnotherStatelessService_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>
And your service now answers to
fabric:/app_name/AwesomeService
You can use this uri builder (ServiceUriBuilder.cs) class from here: https://github.com/Azure-Samples/service-fabric-dotnet-web-reference-app/blob/master/ReferenceApp/Common/ServiceUriBuilder.cs
For stateless service you can easily get the proxy:
var serviceUri = new ServiceUriBuilder(ServiceName);
var proxyFactory = new ServiceProxyFactory();
var svc = proxyFactory.CreateServiceProxy<IServiceName>(serviceUri.ToUri());
For stateful service you have to specify the partition.
var serviceUri = new ServiceUriBuilder(StatefulServiceName);
var proxyFactory = new ServiceProxyFactory();
//this is just a sample of partition 1 if you are using number partitioning.
var partition = new ServicePartitionKey(1);
var svc = proxyFactory.CreateServiceProxy<IStatefulServiceName>(serviceUri.ToUri(), partition);