Service Broker external activator... activate on 2 queues? - sql-server-2008

I have 2 queues and more to come... I want to have those queues externally activated using the external activator.
When I edit the EAService.config to activate queue#1 it works just fine.
When I edit the EAService.config to activate queue#2 it works just fine.
If I put both in the config only the one listed first gets activated.
Both queues are actually getting processed by the same exe... and example of what doesn't work is this...
<NotificationServiceList>
<NotificationService name="my_notif_svc1" id="100" enabled="true">
<Description>my notification service 1</Description>
<ConnectionString>
<Unencrypted>server=my_pc01;database=my_db;Application Name=External Activator;Integrated Security=true;</Unencrypted>
</ConnectionString>
</NotificationService>
<NotificationService name="my_notif_svc2" id="100" enabled="true">
<Description>my notification service 2</Description>
<ConnectionString>
<Unencrypted>server=my_pc01;database=my_db;Application Name=External Activator;Integrated Security=true;</Unencrypted>
</ConnectionString>
</NotificationService>
</NotificationServiceList>
<ApplicationServiceList>
<ApplicationService name="myMessageApp1" enabled="true">
<OnNotification>
<ServerName>my_pc01</ServerName>
<DatabaseName>my_db</DatabaseName>
<SchemaName>dbo</SchemaName>
<QueueName>my_user_queue1</QueueName>
</OnNotification>
<LaunchInfo>
<ImagePath>c:\test\myMessageReceiver.exe</ImagePath>
<CmdLineArgs>whatever cmd-line arguments you need to pass to your receiver application</CmdLineArgs>
<WorkDir>c:\test</WorkDir>
</LaunchInfo>
<Concurrency min="1" max="4" />
</ApplicationService>
<ApplicationService name="myMessageApp2" enabled="true">
<OnNotification>
<ServerName>my_pc01</ServerName>
<DatabaseName>my_db</DatabaseName>
<SchemaName>dbo</SchemaName>
<QueueName>my_user_queue2</QueueName>
</OnNotification>
<LaunchInfo>
<ImagePath>c:\test\myMessageReceiver.exe</ImagePath>
<CmdLineArgs>whatever cmd-line arguments you need to pass to your receiver application</CmdLineArgs>
<WorkDir>c:\test</WorkDir>
</LaunchInfo>
<Concurrency min="1" max="4" />
</ApplicationService>
</ApplicationServiceList>
additionally I don't understand what the id="100" is doing... I tried having same # and different #... ie 100 & 101 but it didn't make a difference. The activator service only works for the first one listed in the "ApplicationServiceList"
help!

I figured out my problem...
From the documentation
Systems can use external activation
for multiple Service Broker
application queues. There is a
many-to-one relationship between
application queues and activation
notification services. There is a
one-to-one relationship between the
Activation Notification service and
the External Activation service.
I was two notification services (my_notif_svc1 & my_notif_svc2) listed above. I switched my event notifications (create event notivation ... ) to utilize the same "TO SERVICE" and now it works.
So you have to utilize one "service" for external activator but you can create multiple Event Notifications for multiple queues which point to that service.
I still think the way I had it set up it should work but this definitely works...

I also ran into this same problem and it would be nice to have an official response from Microsoft as to why and if they will honor multiple notification services listed in SSBEA and not just the first one in the list. In the end we went with the same solution, and here is a helpful snippet to use to dynamically to get the Guid and setup the queue activation event to a SINGLE service (ServiceBrokerNotification.NotificationService).
DECLARE #sbn nvarchar(100) = 'servicebrokernotification'
DECLARE #sbnid nvarchar(60)
SELECT #sbnid = ''''+CAST(service_broker_guid AS nvarchar(60))+'''' FROM sys.databases WHERE name = #sbn
SELECT #sbnid
DECLARE #Str nvarchar(max)
DECLARE #createEventSql nvarchar(max)
Set #Str = 'CREATE EVENT NOTIFICATION NotificationEvent ON QUEUE [TargetQueue]
FOR QUEUE_ACTIVATION TO SERVICE ''NotificationService'' ,' + #sbnid;
Select #Str
EXECUTE (#Str)

Related

ESP8266 and mySQL

To begin with, I set up my database which includes (an id (which is auto increment), username, email, and 2 more which are place0 and place1 (those two are boolean type)). Now my question is how can I connect an esp8266 directly to the database and update the booleans from 0 to 1 and back using a button for each one? Also, how can I read the boolean on the esp and turn an led for example? I need to make it update the values for a selected user not all of them....for example, I have users with id 1, 2, 3...i need to make the updates only on 1 if that one is selected...
Note that both the database and the esp8266 are in my house (on a local network)
Thanks very much
Nikolaos Konstantinou
NcCon
The best way I can think of is ESP8266 to Web Server(PHP/Python/NodeJS etc) to MySQL
Send the boolean values in the form of the HTTP Post method and handle the post method in Webserver then update the MYSQL table.
check out this link
For some reason, if you want to avoid webserver you can try micro python upymysql module which helps to directly communicate the database from ESP board uPyMySQL

SnappyData submit a jar to cluster with parameters

SnappyData documentation give an example on how to submit a jar to a cluster:
https://snappydatainc.github.io/snappydata/howto/run_spark_job_inside_cluster/
But what if I need to submit the jar with the same class CreatePartitionedRowTable
multiple times, but with different paramter, say different suffix to append to the names of the tables created, How do I do that?
UPDATE:
To be more precise, say I want to submit the jar with different parameters when I submit the jar, something like this
bin/snappy-job.sh submit
--app-name CreatePartitionedRowTable
--class org.apache.spark.examples.snappydata.CreatePartitionedRowTable
--app-jar examples/jars/quickstart.jar
--lead localhost:8090
--CustomeParam suffix
the additional
--CustomeParam suffix
will be passed in to the job, and the code can pick up this parameter suffix, and appending the suffix to the table names to be created, so that I don't have to modify my code every time that I want to submit the jar with a different suffix.
Update 2:
I just went through the examples and found an example usage:
https://github.com/SnappyDataInc/snappydata/blob/master/examples/src/main/scala/org/apache/spark/examples/snappydata/CreateColumnTable.scala
so basically run like this:
* bin/snappy-job.sh submit
* --app-name CreateColumnTable
* --class org.apache.spark.examples.snappydata.CreateColumnTable
* --app-jar examples/jars/quickstart.jar
* --lead [leadHost:port]
* --conf data_resource_folder=../../quickstart/src/main/resources
and use config to get the customized parameter.
Each time you submit your app jar with snappy-job.sh it will create a new Job and run it. It could be the same jar with different content. Do you see any exception or the modified class (CreatePartitionedRowTable) is not getting picked ?

Register custom audit events for billing

We are running a custom app on Invantive Data Access Point which adds business functionality to Exact Online. For billing purposes, we would like to somehow register actual use of the software as defined in business terms instead of memory used, CPU, SQL statements executed, etc.
We do not yet have custom tables and I would like to keep it that way, so the whole state is kept in memory and in Exact Online only. So "insert into mytable#sqlserver..." is not an option. Neither does Exact Online offer the possibility to create custom tables as with Salesforce.
How can we somehow register billable events, such as "Performed an upload of 8 bank transactions" under this condition?
For billing purposes, you can lift along on the Customer Service infrastructure, which is similar to functionality offered by AWS or Apple for this purpose in their eco system. The "table" which stores the billing events like a Call Detail Record of a PBX is managed by Customer Service infrastructure.
There are two options:
Your apps use the default audit and license event registrations like "User logged on", "First use of partition #xyz", etc. each with a specific message code like 'itgenlic125'.
Your apps define their own event types like "Performed an upload of bank transactions", with a message code 'mybillingmessagecode123' and the number '8' as quantity in the natural key.
The first option is automatically and always done. These data is also used to manage resource consumption and detect runaways.
The second option is best done using Invantive SQL with the data dictionary table "auditevents". All records inserted into auditevents are automatically asynchronously forwarded to Customer Service. To see the current register audit events since start of application:
select *
from auditevents#datadictionary
where:
occurrence_date: when it happened.
logging_level: always "Audit".
message_code: code identifying the type of event.
data_container_d: ID of the data container, used with distributed SQL transactions.
partition: partition within the data container for platforms such as Exact Online or Microsoft SQL Server which store multiple databases under one customer/instance.
session_id: ID of the session.
user_message: actual text.
last_nk: last used natural key
application_name: name of the appplication.
application_user: user as known to the application.
gui_action: action within the GUI.
And some auditing and licensing information fields.
To register a custom event:
insert into auditevents#datadictionary select * from auditevents#datadictionary
Only some fields can be provided; the rest are automatically determined:
message_code
user_message
last_natural_key
application_name
application_user
gui_action
gui_module
partition
provider_name
reference_key
reference_table_code
session_id
To receive the billing events yourself from the infrastructure, you will need to access the Customer Service APIs or have them automatically forwarded to mail, Slack, RocketChat or Mattermost channel.
A sample SQL:
insert into auditevents#datadictionary
( message_code
, user_message
, last_natural_key
, application_name
, gui_action
, gui_module
, reference_key
, reference_table_code
, partition
)
select 'xxmycode001' message_code
, 'Processed PayPal payments in Exact Online for ' || divisionlabel user_message
, 'today' last_natural_key
, 'PayPalProcessor' application_name
, 'xx-my-paypal-processor-step-2' gui_action
, 'xx-my-payal-processor' gui_module
, clr_id reference_key
, 'clr' reference_table_code
, division partition
from settings#inmemorystorage

Jenkins Promotion Parameter values not coming through in Shell Exec Command

I have created build promotion "choice" parameter named "RUNSCRIPT" with values "No" (as default) and "Yes" and trying to get the value of parameter in EXEC SHELL command as $RUNSCRIPT but neither value "Yes" or "No" coming through. If I look at the output it comes as $RUNSCRIPT (as it is). Why is not being replaced with value. Any suggestions? Also, tried to create other type of parameters e.g. String value but its not working as well.
If you want to pass a value from jenkins to a script you need to define the parameter as jenkins environment variable. I have used Ant for this. For example :
property environment="env"
property name="user" value="${env.user}"
if I just use
property name="user" value="${user}"
the values will be passed from some other file that is referring user.
I managed to get an Approval Parameter to be passed as a Build Parameter on a downstream build (triggered by the promotion itself); you simply need to pass them on.
I learned that Approval parameters are allowed within the approval "build" so to speak, so any actions you have in that approval should be able to reference any of the Approval parameters.
This means you can have an approval parameter FOO, and then in the approval actions, if you have a "Trigger parameterized build" action, you can use a "Predefined parameters" with the text:
BAR=${FOO}
The triggered build will then have the BAR build proprerty set with the value of whatever the build was promoted with.

Linq 2 SQL on shared host

I recently ran into an issue with linq on a shared host.
The host is Shared Intellect and they support v3.5 of the framework. However, I am uncertain to whether they have SP1 installed. My suspicion is that they do not.
I have a simple News table that has the following structure:
NewsID uniqueidentifier
Title nvarchar(250)
Introduction nvarchar(1000)
Article ntext
DateEntered datetime (default getdate())
IsPublic bit (default true)
My goal is to display the 3 most recent records from this table. I initially went the D&D method (I know, I know) and created a linq data-source and was unable to find a way to limit the results the way I desired, so I removed that and wrote the following:
var dc = new NewsDataContext();
var news = from a in dc.News
where a.IsPublic == true
orderby a.DateEntered descending
select new { a.NewsID, a.Introduction };
lstNews.DataSource = news.Take(3);
lstNews.DataBind();
This worked perfectly on my local machine.
However, when I uploaded everything to the shared host, I recieved the following error:
.Read_<>f__AnonymousType0`2
(System.Data.Linq.SqlClient.Implementation.ObjectMaterializer`1<System.Data.SqlClient.SqlDataReader>)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MethodAccessException:
.Read_<>f__AnonymousType0`2
(System.Data.Linq.SqlClient.Implementation.ObjectMaterializer`1<System.Data.SqlClient.SqlDataReader>)
I tried to search the error on Google, but met with no success. I then tried to modify my query in every way I could imagine, removing various combinations of the where/orderby parameters as well as limiting my query to a single column and even removing the Take command.
My Question therefore comes in 3 parts:
Has anyone else encountered this and if so, is there a "quick" fix?
Is there a way to use the datasource to limit the rows?
Is there some way to determine what version of the framework the shared host is running short of emailing them directly (which I have done and am awaiting an answer)
System.MethodAccessException is thrown by the framework when it is missing an assembly, or one of the references are of the wrong version.
The first thing I would do is try uploading and referencing your code to the LINQ assemblies in your BIN, instead of the shared hosting providers GAC.