我在WebLogic Server 12c
中配置了一个@MessageDriven(name="MyListener",activationConfig = {
@ActivationConfigProperty(propertyName = "initialContextFactory", propertyValue = "weblogic.jndi.WLInitialContextFactory"),
@ActivationConfigProperty(propertyName = "connectionFactoryJndiName", propertyValue = "jms/Spry"),
@ActivationConfigProperty(propertyName = "destinationJndiName", propertyValue = "jms/SP_ACC_RQ") ,
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") })
public class MyListener implements MessageListener {
@Override
public void onMessage(Message message) {
try{
MyProcessBusinessImpl businessImpl = new MyProcessBusinessImpl();
TextMessage textMessage = (TextMessage) message;
msgText = textMessage.getText();
businessImpl.startAssessment(msgText);
}catch(Exception e){
// log exception
}
}
}
。侦听器读取消息后,将调用另一个Web服务。当消息计数很高时,另一个Web服务将由于尝试使用同一服务的线程过多而失败。
WebLogic中是否有一种方法可以限制可以从JMS队列读取的消息数?说,我想一次读取10条消息,并且仅当其中一个线程完成执行时才读取11条消息。
监听器类:
maxMessagesInTransaction
我曾尝试在@ActivationConfigProperty
中使用WorkManager
注释,也曾在WebLogic管理控制台中尝试过import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Ullmann {
private ArrayList<Graph> mygraphdb;
private ArrayList<Graph> querys;
public Ullmann() {
setMygraphdb(new ArrayList<Graph>());
setQuerys(new ArrayList<Graph>());
}
public ArrayList<Graph> getMygraphdb() {
return mygraphdb;
}
public void setMygraphdb(ArrayList<Graph> mygraphdb) {
this.mygraphdb = mygraphdb;
}
public ArrayList<Graph> getQuerys() {
return querys;
}
public void setQuerys(ArrayList<Graph> querys) {
this.querys = querys;
}
public int[][] getM0(Graph query, Graph graphdb) {
int row = query.getVertexes().size();
int col = graphdb.getVertexes().size();
int[][] M0 = new int[row][col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
String vi = query.getVertexes().get(i).getVertex();
String vj = graphdb.getVertexes().get(j).getVertex();
int vi_inDeg = query.getVInDegree(vi);
int vi_outDeg = query.getVOutDegree(vi);
String vi_label = query.vertexes.get(i).getLabel();
int vj_inDeg = graphdb.getVInDegree(vj);
int vj_outDeg = graphdb.getVOutDegree(vj);
String vj_label = graphdb.vertexes.get(j).getLabel();
if ((vj_outDeg >= vi_outDeg)&&(vj_inDeg >= vi_inDeg)&&(vi_label.equals(vj_label))){
M0[i][j] = 1;
}else {
M0[i][j] = 0;
}
}
}
return M0;
}
public int[][] getRefinement(Graph subgraph,Graph graphdb,int[][] MA, int[][] MB, int[][] M0){
for (int i = 0; i < subgraph.vertexes.size(); i++) {
for (int j = 0; j < graphdb.vertexes.size(); j++) {
if (M0[i][j] == 0) {
continue;
}// else M0[i][j] = 1
String i_nodeLabel = subgraph.vertexes.get(i).getLabel();
String j_nodeLabel = graphdb.vertexes.get(j).getLabel();
if (i_nodeLabel.equals(j_nodeLabel)) {
for (int x = 0; x < subgraph.vertexes.size(); x++) {
if (MA[i][x] == 1) {
boolean flag = false;
String edgeLabel_ix = subgraph.getLabelByV(String.valueOf(i), String.valueOf(x));
for (int y = 0; y < graphdb.vertexes.size(); y++) {
if (M0[x][y] * MB[y][j] == 1) {
String edgeLabel_jy = graphdb.getLabelByV(String.valueOf(j), String.valueOf(y));
if (edgeLabel_ix.equals(edgeLabel_jy)) {
flag = true;
break;
}
}
}
if (!flag) {
M0[i][j] = 0;
break;
}
}
}
} else {
M0[i][j] = 0;
}
}
}
return M0;
}
public boolean isRowEqualZero(int[][] M0,int row,int col) {
for(int i = 0;i < row;i++) {
int sum = 0;
for(int j = 0;j < col;j++) {
sum += M0[i][j];
}
if(sum==0) {
return true;
}
}
return false;
}
public boolean match(Graph subgraph, Graph graphdb) {
int M0[][] = getM0(subgraph, graphdb);
int MA[][] = subgraph.getMatrix();
int MB[][] = graphdb.getMatrix();
M0 = this.getRefinement(subgraph,graphdb,MA, MB, M0);
int row = subgraph.vertexes.size();
int col = graphdb.vertexes.size();
if(this.isRowEqualZero(M0,row,col)) {
return false;
}
int F[] = new int[col];
int H[] = new int[row];
int d = 0;
int k = 0;
int[][][] matrixList = new int[row][][];
for (int i = 0; i < F.length; i++) {
F[i] = -1;
}
for (int i = 0; i < H.length; i++) {
H[i] = -1;
}
while (true) {
if (H[d] == -1) {
k = 0;
matrixList[d] = M0;
} else {
k = H[d] + 1;
F[H[d]] = -1;
M0 = matrixList[d];
}
while (k < col) {
if (M0[d][k] == 1 && F[k] == -1) {
break;
}
k++;
}
if (k == col) {
H[d] = -1;
d--;
} else {
for (int j = 0; j < col; j++) {
M0[d][j] = 0;
}
M0[d][k] = 1;
H[d] = k;
F[k] = 1;
d++;
}
if (d == -1) {
return false;
}
if (d == row) {
if (this.isTrueFor(MA, MB, M0)) {
return true;
}else {
d = row - 1;
}
}
}
}
public boolean isTrueFor(int[][] MA, int[][] MB, int[][] M) {
int row = M.length;
int col = MB[0].length;
int tmp[][] = new int[row][col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
for (int k = 0; k < M[0].length; k++) {
tmp[i][j] += M[i][k] * MB[k][j];
}
}
}
int tmp_t[][] = new int[col][row];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
tmp_t[j][i] = tmp[i][j];
}
}
int MC[][] = new int[col][row];
for (int i = 0; i < MA.length; i++) {
for (int j = 0; j < MA[0].length; j++) {
for (int k = 0; k < M[0].length; k++) {
MC[i][j] += M[i][k] * tmp_t[k][j];
}
}
}
for (int i = 0; i < MA.length; i++) {
for (int j = 0; j < MA[0].length; ++j) {
if (MA[i][j] == 1) {
if (MC[i][j] == 1)
continue;
else
return false;
}
}
}
return true;
}
public void loadfile(String dbfile, String qfile) throws IOException {
BufferedReader dbreader = new BufferedReader(new InputStreamReader(new FileInputStream(dbfile)));
String line = dbreader.readLine();
Graph curg;
if (line.startsWith("t #")) {
curg = new Graph();
while ((line = dbreader.readLine()) != null) {
if (line.startsWith("t #")) {
this.mygraphdb.add(curg);
curg = new Graph();
continue;
} else if (line.startsWith("v")) {
String vs[] = line.split(" ");
Vertex tmpv = new Vertex();
tmpv.setVertex(vs[1]);
tmpv.setLabel(vs[2]);
curg.vertexes.add(tmpv);
} else if (line.startsWith("e")) {
String es[] = line.split(" ");
Edge tmpe = new Edge();
tmpe.setFrom(es[1]);
tmpe.setTo(es[2]);
tmpe.setLabel(es[3]);
curg.edges.add(tmpe);
}
}
}
BufferedReader qreader = new BufferedReader(new InputStreamReader(new FileInputStream(qfile)));
line = qreader.readLine();
if (line.startsWith("t #")) {
curg = new Graph();
while ((line = qreader.readLine()) != null) {
if (line.startsWith("t #")) {
this.querys.add(curg);
curg = new Graph();
continue;
} else if (line.startsWith("v")) {
String vs[] = line.split(" ");
Vertex tmpv = new Vertex();
tmpv.setVertex(vs[1]);
tmpv.setLabel(vs[2]);
curg.vertexes.add(tmpv);
} else if (line.startsWith("e")) {
String es[] = line.split(" ");
Edge tmpe = new Edge();
tmpe.setFrom(es[1]);
tmpe.setTo(es[2]);
tmpe.setLabel(es[3]);
curg.edges.add(tmpe);
}
}
}
}
public static void main(String[] args) {
String dbfile = "graphDB\\G.data";
String qfile = "graphDB\\Q.my";
Ullmann ullmann = new Ullmann();
try {
ullmann.loadfile(dbfile, qfile);
System.out.println("size of my graphdb: " + ullmann.getMygraphdb().size());
System.out.println("size of my querys: " + ullmann.getQuerys().size());
long start = System.currentTimeMillis();
for (int i = 0; i < ullmann.getMygraphdb().size(); i++) {
Graph target = ullmann.getMygraphdb().get(i);
for (int j = 0; j < ullmann.getQuerys().size(); j++) {
Graph query = ullmann.getQuerys().get(j);
if (ullmann.match(query, target)) {
System.out.println("Target #" + i + " matches query #" + j);
}else {
System.out.println("Target #" + i + " not matches query #" + j);
}
}
}
long end = System.currentTimeMillis();
System.out.println("running time: " + (end - start) + "ms");
} catch (IOException e) {
e.printStackTrace();
}
}
,但是这些都不是我的问题的解决方案。