I have made below sample xml and need some help in forming dbus-send command to set/get propoerty "Status". I know how to call methods, but not able to read/write property using dbus-send.
xml:
<node>
<interface name="com.pgaur.GDBUS">
<method name="HelloWorld">
<arg name="greeting" direction="in" type="s"/>
<arg name="response" direction="out" type="s"/>
</method>
<signal name="Notification">
<arg name="roll_number" type="i"/>
<arg name="name" type="s"/>
</signal>
<property name="Status" type="u" access="readwrite"/>
</interface>
</node>
You can Get/Set DBus properties for your DBus interface using below dbus-send commands. Replace $BUS_NAME and $OBJECT_PATH with respective names.
Get Property:
dbus-send --system --dest=$BUS_NAME --print-reply $OBJECT_PATH \
org.freedesktop.DBus.Properties.Get string:com.pgaur.GDBUS string:Status
Set Property:
dbus-send --system --dest=$BUS_NAME --print-reply $OBJECT_PATH \
org.freedesktop.DBus.Properties.Set string:com.pgaur.GDBUS string:Status variant:uint32:10
You can read DBus specification to know more about DBus Properties.
dbus-send --system --print-reply --type=method_call --dest=org.ofono /gemalto_0 org.ofono.Modem.SetProperty string:"Powered" variant:boolean:false
Related
I am beginner for camel. I have some problem.
We are implementing file transfer system using camel.
I set property from external property file.
But application is not accessed to this property file. We cannot use propertyplaceholder because the value will be changed at runtime.
We implemented it like below.
camelContext.xml :
<bean id="myProperties" class="java.util.Properties"/>
<bean id="propertylist"
class="org.apache.camel.component.properties.PropertiesComponent">
<property name="cache" value="true"/>
<property name="location" value="classpath:camelap.properties"/>
<property name="overrideProperties" ref="myProperties"/>
</bean>
<camelContext id="camelContext-f611cb6c-d516-4346-9adc-5512d327a88d"
trace="false" xmlns="http://camel.apache.org/schema/spring">
<camel:route id="initial_info">
<camel:from id="_initial" uri="direct:sqlParam"/>
<camel:to id="_selectReference" uri="sql:{{sql.referenceInfo}}?
dataSource=dataSource"/>
<camel:process id="_process1" ref="tempBean"/>
<camel:log id="_aaaa" loggingLevel="WARN" message="tttttttt :::
{{test}} ::: ${header.sourceDirectory}"/>
</camel:route>
camelap.properties :
path : target/classes
file.uri=/home/WRK/KR/SND/DAT
test=OLD_VALUE
file.pattern=SLPNPM*,SPLNCC*,SLPNCM*,SLPNPC*
############################################
## SQL Statement ##
############################################
sql.referenceInfo=SELECT DISTINCT \
A.WFLOW_INST_ID ,\
TO_CHAR(A.EFCT_ST_DT,'YYYYMMDDHH24MISS') EFCT_ST_DT, \
B.NE_ID , \
B.NE_TYPE_ID , \
B.CDR_FILE_COLEC_DIR_NM , \
B.ORIGIN_FMT_ID , \
B.TRM_DIR_NM , \
D.CDR_FILE_NMNG_RULE_SBST, \
D.FILE_NM_LEN , \
B.FNS_FILE_CRET_YN , \
B.FNS_FILE_DIV_CD \
FROM TB_WFLOW_INFO A, \
TB_CDRSEND_BASE_INFO B, \
TB_FILE_FMT_INFO D \
WHERE A.WFLOW_INST_ID = 'P1_IPTVKR' \
AND B.NE_ID = 'KRLPPM10' \
AND now() BETWEEN A.EFCT_ST_DT AND A.EXP_DT \
AND now() BETWEEN B.EFCT_ST_DT AND B.EXP_DT \
AND A.WFLOW_INST_ID = B.WFLOW_INST_ID \
AND B.ORIGIN_FMT_ID = D.CDR_FILE_FMT_ID;
Error Log :
org.apache.camel.RuntimeCamelException:
org.apache.camel.FailedToCreateRouteException: Failed to create route initial_info at: >>> To[sql:{{sql.referenceInfo}}?dataSource=dataSource] <<< in route: Route(initial_info)[[From[direct:sqlParam]] -> [To[sql:{{sql... because of Property with key [sql.referenceInfo] not found in properties from text: sql:{{sql.referenceInfo}}?dataSource=dataSource
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1826) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:136) ~[camel-spring-2.23.1.jar:2.23.1]
at org.apache.camel.spring.CamelContextFactoryBean.start(CamelContextFactoryBean.java:370) ~[camel-spring-2.23.1.jar:2.23.1]
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:417) ~[camel-spring-2.23.1.jar:2.23.1]
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:95) ~[camel-spring-2.23.1.jar:2.23.1]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at com.ktds.openmzn.OpenmznApplication.main(OpenmznApplication.java:25) ~[classes/:na]
.....
Caused by: java.lang.IllegalArgumentException: Property with key [sql.referenceInfo] not found in properties from text: sql:{{sql.referenceInfo}}?dataSource=dataSource
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:271) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:157) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParse(DefaultPropertiesParser.java:116) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:100) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:63) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:235) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:178) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:2547) ~[camel-core-2.23.1.jar:2.23.1]
If you want to use the properties component, you need to bind a name with properties, just like this.
<camelContext trace="{{foo.trace}}" xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="properties" location="org/apache/camel/spring/processor/myprop.properties"/>
<template id="camelTemplate" defaultEndpoint="{{foo.cool}}"/>
<route>
<from uri="direct:start"/>
<setHeader headerName="{{foo.header}}">
<simple>${in.body} World!</simple>
</setHeader>
<to uri="mock:result"/>
</route>
</camelContext>
You can find more information here
Not sure if you are using spring boot, there is a simple way to leverage the spring boot properties within Camel Route.
Given libdbus-1 which is non-negotiable, I'd like to implement Get and GetAll for DBus properties.
I don't really see any examples for this.
Do I just have to match the method with dbus_message_is_method_call() and respond accordingly?
Or is there a built in way of doing this where I have some code to do the heavy lifting.
Once again, switching libraries is not an option so please don't say use Qt, glib, libnih, libsystemd, or anything else. Please be specific to libdbus-1 or don't answer.
Look at the libdbus-1 source code: git://anongit.freedesktop.org/dbus/dbus
There's an example here in bus/driver.c called bus_driver_handle_get_all(). This function implements a reply to "GetAll".
Of course, we need to have GetAll implemented in our xml file for introspection as well.
<interface name='org.freedesktop.DBus.Properties'>
<method name='Get'>
<arg name='interface' type='s' direction='in' />
<arg name='property' type='s' direction='in' />
<arg name='value' type='s' direction='out' />
</method>
<method name='GetAll'>
<arg name='interface' type='s' direction='in'/>
<arg name='properties' type='a{sv}' direction='out'/>
</method>
</interface>
So to reply to this, we need to iterate through all of our properties and load them up in a DBusMessageIter then send this reply to the sender.
Clearly the "Get" response is much easier, we merely have to return a string in this case which is obviously matched for our property. Again, this is in the same file, bus/driver.c in the function: bus_driver_handle_get().
I am inserting into three tables using Box_caring feature, insertion happening properly but if some error comes in between while inserting into tables its not roll backing the data.
I'm looking for a solution to the following challenge:Have a set of related tables. They are related by primary/foreign key relations and need to update/insert objects in the related tables. Insert/update happening inside iterator mediator. what happens when one of the updates/insert fails? Will all the inserted/updated objects rolled back?.
Please give any ideas or links or code snippet to make it work.
Note: Am using wso2 esb-4.8.1, wso2 dss-3.2.2 and MSSQL database
Gone through below links:
http://charithaka.blogspot.in/2014/02/common-mistakes-to-avoid-in-wso2-esb-1.html
How we can ROLLBACK the Transaction in WSO2DSS or WSO2ESB
Thanks in advance
Here you have to implement Distributed XA transactions. Could you please refer to the article [1] which will guide you through this.
[1]https://docs.wso2.com/display/ESB490/Sample+657%3A+Distributed+Transaction+Management
When you are using box_carring feature, you have to maintain same session across all the operation calls. Otherwise, it will evaluates as separated calls and will not be atomic. Here is a sample synapse config that can be used to maintain the same session.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="ESBService"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<transaction action="new"/>
<property name="id" expression="json-eval($.id)"/>
<property name="userName" expression="json-eval($.userName)"/>
<property name="firstName" expression="json-eval($.firstName)"/>
<property name="lastName" expression="json-eval($.lastName)"/>
<property name="address" expression="json-eval($.address)"/>
<enrich>
<source type="body" clone="true"/>
<target type="property" property="FirstBody"/>
</enrich>
<property name="messageType" value="application/xml" scope="axis2"/>
<header name="Action" value="urn:begin_boxcar"/>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dat="http://ws.wso2.org/dataservice">
<soapenv:Header/>
<soapenv:Body>
<dat:begin_boxcar/>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args/>
</payloadFactory>
<call>
<endpoint>
<address uri="http://localhost:9764/services/testService.SOAP11Endpoint/"/>
</endpoint>
</call>
<property name="setCookieHeader" expression="$trp:Set-Cookie"/>
<property name="Cookie"
expression="get-property('setCookieHeader')"
scope="transport"/>
<property name="OUT_ONLY" value="true"/>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dat="http://ws.wso2.org/dataservice">
<soapenv:Header/>
<soapenv:Body>
<p:insert_employee xmlns:p="http://ws.wso2.org/dataservice">
<xs:UserId xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:UserId>
<xs:userName xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:userName>
<xs:firstName xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:firstName>
<xs:lastName xmlns:xs="http://ws.wso2.org/dataservice">$4</xs:lastName>
</p:insert_employee>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="get-property('id')"/>
<arg evaluator="xml" expression="get-property('userName')"/>
<arg evaluator="xml" expression="get-property('firstName')"/>
<arg evaluator="xml" expression="get-property('lastName')"/>
</args>
</payloadFactory>
<property name="Content-Encoding" scope="transport" action="remove"/>
<property name="Cookie"
expression="get-property('setCookieHeader')"
scope="transport"/>
<call>
<endpoint>
<address uri="http://localhost:9764/services/testService.SOAP11Endpoint/"/>
</endpoint>
</call>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dat="http://ws.wso2.org/dataservice">
<soapenv:Header/>
<soapenv:Body>
<dat:end_boxcar/>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args/>
</payloadFactory>
<property name="Content-Encoding" scope="transport" action="remove"/>
<property name="Cookie"
expression="get-property('setCookieHeader')"
scope="transport"/>
<call>
<endpoint>
<address uri="http://localhost:9764/services/testService.SOAP11Endpoint/"/>
</endpoint>
</call>
<respond/>
</inSequence>
<faultSequence>
<log>
<property name="END" value="****ROLLBACK****"/>
</log>
<transaction action="rollback"/>
<respond/>
</faultSequence>
</target>
</proxy>
However, you can use request_box feature, where you do not have to maintain the session across operations.
Thanks
I implement an app with this com.example.appname.desktop file as follows:
$ cat /usr/local/share/applications/com.example.appname.desktop
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=appname
Exec=/opt/app/appname %u
DBusActivatable=true
Categories=Network;
MimeType=x-scheme-handler/itmm;
NoDisplay=false
$ cat /usr/share/dbus-1/services/com.example.appname.service
[D-BUS Service]
Name=com.example.appname
Exec=/opt/app/appname
Introspection XML looks like this:
$ qdbus com.example.appname /com/example/appname org.freedesktop.DBus.Introspectable.Introspect
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.Application">
<method name="ActivateAction">
<arg name="action_name" type="s" direction="in"/>
<arg name="parameter" type="av" direction="in"/>
<arg name="platform_data" type="a{sv}" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In2" value="QVariantMap"/>
</method>
<method name="Activate">
<arg name="platform_data" type="a{sv}" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
</method>
<method name="Open">
<arg name="uris" type="as" direction="in"/>
<arg name="platform_data" type="a{sv}" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="out"/>
</method>
----<snipped>-----
But when i try to launch the method it gives me an error:
$ gapplication launch com.example.appname
error sending Activate message to application: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such method 'Activate' in interface 'org.freedesktop.Application' at object path '/com/example/appname' (signature 'a{sv}')
Is "annotation name=.." XML tag (see introspection XML) the reason this method is not found?
Browsing to itmm://192.168.1.1/query?version=1.0 via browser launches the application with command line parameter, but it is not launched via D-Bus service and thats what my requirement is. Is there a way to debug this via firefox or google chrome browsers?
I use QT's D-Bus binding to implement D-Bus service. My issue were
My class that implemented D-Bus interface was not inheriting QDBusAbstractAdaptor .
Methods to be exported were not marked as public slots
My original class looked like this below:
class DBusService : public Application
{
QOBJECT
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Application")
public:
void Activate(QMap<QString, QVariant> platform_data)
{
Q_UNUSED(platform_data);
}
void Open(QStringList uris, QMap<QString, QVariant> platform_data)
{
Q_UNUSED(platform_data);
if( ! uris.size() ) {
return;
}
QUrl url(uris[0]);
//use url
}
}
Following one works:
class DBusService : public QDBusAbstractAdaptor //<----- Inherit from this class
{
QOBJECT
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Application")
public slots: // <------ mark public slots
void Activate(QMap<QString, QVariant> platform_data)
{
Q_UNUSED(platform_data);
}
void Open(QStringList uris, QMap<QString, QVariant> platform_data)
{
Q_UNUSED(platform_data);
if( ! uris.size() ) {
return;
}
QUrl url(uris[0]);
qApp->MyCustomMethod(url);
}
}
D-Bus debugging tools
These tools helped me debugging D-Bus issues.
dbus-monitor - sniffs traffic on the bus
gapplication - lets you debug DBusActivatable services.
How can I load a value from a property file and pass it as arg when I want to execute a java file?
The content the file of aa.properties:
home_path=C:/myhome/apps
The ant:
<target name="tst">
<property file="aa.properties"/>
<property name="homepath" value="${home_path}/"/>
<java classpathref="clspath" classname="com.mytest.myapp" fork="true">
<arg value="${homepath}"/>
</java>
</target>
you pass it like any other argument to the java task via nested arg values or arg line
Note that vmargs like f.e. -Dwhatever=foobar are passed as jvmarg to the java task
f.e. your propertyfile aa.properties looks like :
vmarg.foo=-Dsomevalue=whatever
arg.key=value
arg.foo=bar
...
ant then
<target name="tst">
<property file="aa.properties"/>
<property name="homepath" value="${home_path}/"/>
<java classpathref="clspath" classname="com.mytest.myapp" fork="true">
<jvmarg value="${vmarg.foo}"/>
<arg value="${homepath}"/>
<arg value="${arg.key}"/>
<arg value="${arg.foo}"/>
...
</java>
</target>