Requirement: Get all connections from dtsx packages using C#.
Solution:
Using Microsoft.SqlServer.Dts.Runtime to load the package, and then get all connections.
In case you are totally new to .Net/C#, you may need this screen capture:
In the pop-up window, click “Browse” tab, and select: C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Microsoft.SQLServer.ManagedDTS.dll
About the dll path:
ref 2: http://stackoverflow.com/questions/4920591/havent-got-microsoft-sqlserver-manageddts-dll-but
import: using Microsoft.SqlServer.Dts.Runtime
public void testDts() { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; pkgLocation = @"C:\Users\x\Documents\Visual Studio 2008\Projects\Integration Services Project1\Integration Services Project1\" + @"Package.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, null); Connections conns = pkg.Connections; foreach (ConnectionManager cm in conns) { Console.WriteLine("Name = " + cm.Name + ", HostType = " + cm.HostType + "; ConnectionString=" + cm.ConnectionString); } }
API: http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.package.connections(v=sql.100).aspx
Output:
Name = Flat File Connection Manager, HostType = ConnectionManager; ConnectionString=C:\Users\x\Desktop\ssisTest.txt
Name = x_instan, HostType = ConnectionManager; ConnectionString=Data Source=x-PC\x_INSTAN;Integrated Security=SSPI;Connect Timeout=30;
After I created a new Class using:
grails> create-domain-class User
I want to to generate the controller:
grails>generate-all User
I got these error:
| No domain class found for name User. Please try again and enter a valid domain class name
| Error Error running generate-all (Use –stacktrace to see the full trace)
| Error Error running script generate-all User: org.codehaus.groovy.grails.cli.ScriptExitException (
Use –stacktrace to see the full trace)
grails> –stacktrace
| Error Error running script –stacktrace: Cannot invoke method findAll() on null object (NOTE: Stac
k trace has been filtered. Use –verbose to see entire trace.)
java.lang.NullPointerException: Cannot invoke method findAll() on null object
at RunApp$_run_closure8_closure13.doCall(RunApp:229)
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.ja
va:1231)
at RunApp$_run_closure8_closure13.doCall(RunApp)
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.ja
va:1231)
| Error Error running script –stacktrace: Cannot invoke method findAll() on null object
The solution is use the class full name:
generate-all helloworld.User
helloworld is my application name. and the User class package is “hellowolrd”.
Many thanks for: generate-all No domain class found for.. error in grails
1. Download Grails, unzip.
2. Add the bin path into PATH
3. run: grails –version, if you not set JAVA_HOME yet, there will be some info about this.
now, you are ready to create the application:
1. Run: grails create-app helloworld there’ll be some mesg about the application path.
Note: can not use this command in “Interactive Mode”
2. cd helloworld
3. Create controller: grails> create-controller hello, get some info after success:
| Created file grails-app/controllers/helloworld/HelloController.groovy
| Created file grails-app/views/hello
| Created file test/unit/helloworld/HelloControllerTests.groovy
4. Modify the controller:
package helloworld class HelloController { def index() { render "Hello World!!" } }
5. Ok, everything is ready, now, just run the application: grails> run-app
Negative to the page, the console will be there, click the application link: “Hello world!!”
非常简单的快速入门: 从Host发送Message到VM.
MQ版本: 7.5
操作系统版本:
主机/Host: Windows 7 64 Home
虚拟机/VM: XP Pro SP3
在IBM.com可直接下载IBM的试用版. (需要登录)
之后的安装非常简单, 不做描述.
依次配置: QueueManager, Queue, Channel:
Name @Host | Name @VM | Remarks | |
Queue Manager | QM_Host | QM_VM | Keep other options default |
Queues | Host_TRAN_Q | VM_LOCAL_RECEIVE_Q | Local queue, Usage: Transmission |
Host_Remote_Send_Q | VM只接受, 因此不需配置. | Remote queue. need config: 1. Remote queue: (For Host, VM is the remote) 2. Remote queue manager: 3. Transmission queue: Ref to screen capture 1 |
|
Channels | HOST_SEND_CHANNEL Ref to screen capture 2 |
HOST_SEND_CHANNEL | [很抱歉, 命名很烂] Host端Type: Sender; VM端: Receiver 保持相同名称. |
ChannelServerConnTes | ChannelServerConnTes | Type:Server-connection, 配置MCA user或保持默认 为Java端配置 |
(配置Remote queue, Remote queue manager, 对Host来说, VM就是Remote, 因此配置为VM中的队列名称)
(发送队列, Connection Name实际为Remote server的IP(port))
由于配置较多, 因此将Host及VM两侧的Queue及Channel抓图如下:
Host:
VM:
在上述Queue manager, Queue, Channel配置妥当之后, 进行测试:
1. 在Host端, 选中HOST_SEND_CHANNEL (Sender)后, 右键 “ping” 测试:
如果测试失败, 关闭或配置防火墙.
2. 放入消息进行测试:
确定两端HOST_SEND_CHANNEL (Sender)启动后(状态应为Running), 在Host端的Host_Remote_Send_Q (Remote) 右键 Put message.
在VM端, 队列中可以看到收到Message:
至此, MQ已经配置完毕并通过测试.
前置条件: 创建type为Server-connection的Channel. 本例中的ChannelServerConnTes, 该Channel无法开启, 创建完毕后供Java端使用.
先拿来用:
http://java-brew.blogspot.sg/2011/01/java-code-to-connect-to-mq.html 或:
http://blog.csdn.net/fenglibing/article/details/4161441
检查防火墙.
如果供Java端使用的Server-connection.MCA中不填入正确的UserID (mqm用户组中的用户), 会导致如下之错误信息:
MQJE001: Completion Code ‘2’, Reason ‘2035’.
解决方法有:
(需要保证该用户在操作系统mqm用户组中)
2. 禁用Channel认证:
运行: IBM\WebSphere MQ\bin\runmqsc.exe:
alter qmqr chlauth(disabled)
由于我的Win7 Home无法管理用户组, 所以直接用第二种方法disable掉channel 认证.
ref: http://space.itpub.net/14789789/viewspace-374497 or http://blog.csdn.net/javalover_yao/article/details/6387460
错误信息:
CC=2;RC=2539;AMQ9204: Connection to host ‘192.168.1.220(1414)’ rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2539;AMQ9547: Type of remote channel not suitable for action requested. [3=HOST_SEND_CHANNEL]],3=192.168.1.220(1414),5=RemoteConnection.analyseErrorSegment]
使用了错误的Channel, 供Java使用的Channel type应为: Server-connection.
com.ibm.mq.MQException: MQJE001: Completion Code ‘2’, Reason ‘2009’.
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2009;AMQ9204: Connection to host ‘192.168.1.220(1414)’ rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2009;AMQ9208: Error on receive from host ‘/192.168.1.220:1414 (Guoliang-PC)’. [1=-1,2=ffffffff,3=/192.168.1.220:1414 (Guoliang-PC),4=TCP]],3=192.168.1.220(1414),5=RemoteConnection.receiveTSH]
检查MQEnvironment是否设置了编码CCSID. 如:MQEnvironment.CCSID=1381;
百度文档:
MQ 服务器配置与测试一例 http://wenku.baidu.com/view/a6e30117866fb84ae45c8d92.html
MQ安装和配置 http://wenku.baidu.com/view/d0f1a16a561252d380eb6e1d.html
(完)
最近, 一个我很欣赏的程序员频繁的使用360产品
竟然称: “最牛的压缩技术 2G—>158K”
— 完全不顾我的感受, 毫不尊重自己的节操. 对此, 我深表失望. 请看我花一早晨时间捣鼓的东西:
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.